Deleted Added
full compact
ethernet-common.c (226024) ethernet-common.c (231987)
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>
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 226024 2011-10-04 20:17:43Z marcel $");
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
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;
49
50/**
51 * Set the multicast list. Currently unimplemented.
52 *
53 * @param dev Device to work on
54 */
55void cvm_oct_common_set_multicast_list(struct ifnet *ifp)
56{

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

85 cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM_EN(index, interface), 1);
86
87 cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64);
88 }
89}
90
91
92/**
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/**
93 * Set the hardware MAC address for a device
94 *
95 * @param dev Device to change the MAC address for
96 * @param addr Address structure to change it too.
97 */
98void cvm_oct_common_set_mac_address(struct ifnet *ifp, const void *addr)
99{
100 cvm_oct_private_t *priv = (cvm_oct_private_t *)ifp->if_softc;

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

263/**
264 * Per network device initialization
265 *
266 * @param dev Device to initialize
267 * @return Zero on success
268 */
269int cvm_oct_common_init(struct ifnet *ifp)
270{
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{
271 char mac[6] = {
272 cvmx_sysinfo_get()->mac_addr_base[0],
273 cvmx_sysinfo_get()->mac_addr_base[1],
274 cvmx_sysinfo_get()->mac_addr_base[2],
275 cvmx_sysinfo_get()->mac_addr_base[3],
276 cvmx_sysinfo_get()->mac_addr_base[4],
277 cvmx_sysinfo_get()->mac_addr_base[5] };
304 uint8_t mac[6];
278 cvm_oct_private_t *priv = (cvm_oct_private_t *)ifp->if_softc;
279
305 cvm_oct_private_t *priv = (cvm_oct_private_t *)ifp->if_softc;
306
280 mac[5] += cvm_oct_mac_addr_offset++;
307 if (cvm_assign_mac_address(NULL, mac) != 0)
308 return ENXIO;
281
282 ifp->if_mtu = ETHERMTU;
283
284 cvm_oct_mdio_setup_device(ifp);
285
286 cvm_oct_common_set_mac_address(ifp, mac);
287 cvm_oct_common_change_mtu(ifp, ifp->if_mtu);
288

--- 25 unchanged lines hidden ---
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 ---