Deleted Added
sdiff udiff text old ( 226024 ) new ( 231987 )
full compact
1/*************************************************************************
2Copyright (c) 2003-2007 Cavium Networks (support@cavium.com). All rights
3reserved.
4
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are
8met:

--- 14 unchanged lines hidden (view full) ---

23This Software, including technical data, may be subject to U.S. export control laws, including the U.S. Export Administration Act and its associated regulations, and may be subject to export or import regulations in other countries.
24
25TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
26AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
27
28*************************************************************************/
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/mips/cavium/octe/ethernet-common.c 231987 2012-02-22 01:30:25Z gonzo $");
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/bus.h>
36#include <sys/endian.h>
37#include <sys/kernel.h>
38#include <sys/mbuf.h>
39#include <sys/socket.h>
40
41#include <net/ethernet.h>
42#include <net/if.h>
43
44#include "wrapper-cvmx-includes.h"
45#include "ethernet-headers.h"
46
47extern int octeon_is_simulation(void);
48
49static uint64_t mac_addr = 0;
50static uint32_t mac_offset = 0;
51
52/**
53 * Set the multicast list. Currently unimplemented.
54 *
55 * @param dev Device to work on
56 */
57void cvm_oct_common_set_multicast_list(struct ifnet *ifp)
58{

--- 28 unchanged lines hidden (view full) ---

87 cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM_EN(index, interface), 1);
88
89 cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64);
90 }
91}
92
93
94/**
95 * Assign a MAC addres from the pool of available MAC addresses
96 * Can return as either a 64-bit value and/or 6 octets.
97 *
98 * @param macp Filled in with the assigned address if non-NULL
99 * @param octets Filled in with the assigned address if non-NULL
100 * @return Zero on success
101 */
102int cvm_assign_mac_address(uint64_t *macp, uint8_t *octets)
103{
104 /* Initialize from global MAC address base; fail if not set */
105 if (mac_addr == 0) {
106 memcpy((uint8_t *)&mac_addr + 2, cvmx_sysinfo_get()->mac_addr_base, 6);
107 if (mac_addr == 0)
108 return ENXIO;
109 }
110
111 if (mac_offset >= cvmx_sysinfo_get()->mac_addr_count)
112 return ENXIO; /* Out of addresses to assign */
113
114 if (macp)
115 *macp = mac_addr;
116 if (octets)
117 memcpy(octets, (u_int8_t *)&mac_addr + 2, 6);
118
119 mac_addr++;
120 mac_offset++;
121
122 return 0;
123}
124
125/**
126 * Set the hardware MAC address for a device
127 *
128 * @param dev Device to change the MAC address for
129 * @param addr Address structure to change it too.
130 */
131void cvm_oct_common_set_mac_address(struct ifnet *ifp, const void *addr)
132{
133 cvm_oct_private_t *priv = (cvm_oct_private_t *)ifp->if_softc;

--- 162 unchanged lines hidden (view full) ---

296/**
297 * Per network device initialization
298 *
299 * @param dev Device to initialize
300 * @return Zero on success
301 */
302int cvm_oct_common_init(struct ifnet *ifp)
303{
304 uint8_t mac[6];
305 cvm_oct_private_t *priv = (cvm_oct_private_t *)ifp->if_softc;
306
307 if (cvm_assign_mac_address(NULL, mac) != 0)
308 return ENXIO;
309
310 ifp->if_mtu = ETHERMTU;
311
312 cvm_oct_mdio_setup_device(ifp);
313
314 cvm_oct_common_set_mac_address(ifp, mac);
315 cvm_oct_common_change_mtu(ifp, ifp->if_mtu);
316

--- 25 unchanged lines hidden ---