Deleted Added
full compact
ethernet.c (215959) ethernet.c (215974)
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:

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

22
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#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:

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

22
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#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/mips/cavium/octe/ethernet.c 215959 2010-11-28 00:26:08Z jmallett $");
30__FBSDID("$FreeBSD: head/sys/mips/cavium/octe/ethernet.c 215974 2010-11-28 05:57:24Z jmallett $");
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/bus.h>
35#include <sys/conf.h>
36#include <sys/endian.h>
37#include <sys/kernel.h>
38#include <sys/rman.h>

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

69int pow_receive_group = 15;
70TUNABLE_INT("hw.octe.pow_receive_group", &pow_receive_group);
71/*
72 "\t\tPOW group to receive packets from. All ethernet hardware\n"
73 "\t\twill be configured to send incomming packets to this POW\n"
74 "\t\tgroup. Also any other software can submit packets to this\n"
75 "\t\tgroup for the kernel to process." */
76
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/bus.h>
35#include <sys/conf.h>
36#include <sys/endian.h>
37#include <sys/kernel.h>
38#include <sys/rman.h>

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

69int pow_receive_group = 15;
70TUNABLE_INT("hw.octe.pow_receive_group", &pow_receive_group);
71/*
72 "\t\tPOW group to receive packets from. All ethernet hardware\n"
73 "\t\twill be configured to send incomming packets to this POW\n"
74 "\t\tgroup. Also any other software can submit packets to this\n"
75 "\t\tgroup for the kernel to process." */
76
77static int disable_core_queueing = 1;
78TUNABLE_INT("hw.octe.disable_core_queueing", &disable_core_queueing);
79/*
80 "\t\tWhen set the networking core's tx_queue_len is set to zero. This\n"
81 "\t\tallows packets to be sent without lock contention in the packet scheduler\n"
82 "\t\tresulting in some cases in improved throughput.\n" */
83
84extern int octeon_is_simulation(void);
85
86/**
87 * Exported from the kernel so we can determine board information. It is
88 * passed by the bootloader to the kernel.
89 */
90extern cvmx_bootinfo_t *octeon_bootinfo;
91

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

171 IF_UNLOCK(&priv->tx_free_queue[qos]);
172
173 /*
174 * XXX locking!
175 */
176 priv->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
177 }
178 }
77extern int octeon_is_simulation(void);
78
79/**
80 * Exported from the kernel so we can determine board information. It is
81 * passed by the bootloader to the kernel.
82 */
83extern cvmx_bootinfo_t *octeon_bootinfo;
84

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

164 IF_UNLOCK(&priv->tx_free_queue[qos]);
165
166 /*
167 * XXX locking!
168 */
169 priv->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
170 }
171 }
179#if 0
180 cvm_oct_device[port]->get_stats(cvm_oct_device[port]);
181#endif
182 }
183 port++;
184 /* Poll the next port in a 50th of a second.
185 This spreads the polling of ports out a little bit */
186 callout_reset(&cvm_oct_poll_timer, hz / 50, cvm_do_timer, NULL);
187 } else {
188 port = 0;
189 /* If any updates were made in this run, continue iterating at

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

307 int ifnum;
308 int num_interfaces;
309 int interface;
310 int fau = FAU_NUM_PACKET_BUFFERS_TO_FREE;
311 int qos;
312
313 printf("cavium-ethernet: %s\n", OCTEON_SDK_VERSION_STRING);
314
172 }
173 port++;
174 /* Poll the next port in a 50th of a second.
175 This spreads the polling of ports out a little bit */
176 callout_reset(&cvm_oct_poll_timer, hz / 50, cvm_do_timer, NULL);
177 } else {
178 port = 0;
179 /* If any updates were made in this run, continue iterating at

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

297 int ifnum;
298 int num_interfaces;
299 int interface;
300 int fau = FAU_NUM_PACKET_BUFFERS_TO_FREE;
301 int qos;
302
303 printf("cavium-ethernet: %s\n", OCTEON_SDK_VERSION_STRING);
304
315#if 0
316 cvm_oct_proc_initialize();
317#endif
318 cvm_oct_rx_initialize();
319 cvm_oct_configure_common_hw(bus);
320
321 cvmx_helper_initialize_packet_io_global();
322
323 /* Change the input group for all ports before input is enabled */
324 num_interfaces = cvmx_helper_get_number_of_interfaces();
325 for (interface = 0; interface < num_interfaces; interface++) {

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

359
360 dev = BUS_ADD_CHILD(bus, 0, "octe", ifnum++);
361 if (dev != NULL)
362 ifp = if_alloc(IFT_ETHER);
363 if (dev == NULL || ifp == NULL) {
364 printf("\t\tFailed to allocate ethernet device for port %d\n", port);
365 continue;
366 }
305 cvm_oct_rx_initialize();
306 cvm_oct_configure_common_hw(bus);
307
308 cvmx_helper_initialize_packet_io_global();
309
310 /* Change the input group for all ports before input is enabled */
311 num_interfaces = cvmx_helper_get_number_of_interfaces();
312 for (interface = 0; interface < num_interfaces; interface++) {

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

346
347 dev = BUS_ADD_CHILD(bus, 0, "octe", ifnum++);
348 if (dev != NULL)
349 ifp = if_alloc(IFT_ETHER);
350 if (dev == NULL || ifp == NULL) {
351 printf("\t\tFailed to allocate ethernet device for port %d\n", port);
352 continue;
353 }
367 /* XXX/juli set max send q len. */
368#if 0
369 if (disable_core_queueing)
370 ifp->tx_queue_len = 0;
371#endif
372
373 /* Initialize the device private structure. */
374 device_probe(dev);
375 priv = device_get_softc(dev);
376 priv->dev = dev;
377 priv->ifp = ifp;
378 priv->imode = imode;
379 priv->port = port;

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

394 case CVMX_HELPER_INTERFACE_MODE_NPI:
395 priv->init = cvm_oct_common_init;
396 priv->uninit = cvm_oct_common_uninit;
397 device_set_desc(dev, "Cavium Octeon NPI Ethernet");
398 break;
399
400 case CVMX_HELPER_INTERFACE_MODE_XAUI:
401 priv->init = cvm_oct_xaui_init;
354
355 /* Initialize the device private structure. */
356 device_probe(dev);
357 priv = device_get_softc(dev);
358 priv->dev = dev;
359 priv->ifp = ifp;
360 priv->imode = imode;
361 priv->port = port;

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

376 case CVMX_HELPER_INTERFACE_MODE_NPI:
377 priv->init = cvm_oct_common_init;
378 priv->uninit = cvm_oct_common_uninit;
379 device_set_desc(dev, "Cavium Octeon NPI Ethernet");
380 break;
381
382 case CVMX_HELPER_INTERFACE_MODE_XAUI:
383 priv->init = cvm_oct_xaui_init;
402 priv->uninit = cvm_oct_xaui_uninit;
384 priv->uninit = cvm_oct_common_uninit;
403 device_set_desc(dev, "Cavium Octeon XAUI Ethernet");
404 break;
405
406 case CVMX_HELPER_INTERFACE_MODE_LOOP:
407 priv->init = cvm_oct_common_init;
408 priv->uninit = cvm_oct_common_uninit;
409 device_set_desc(dev, "Cavium Octeon LOOP Ethernet");
410 break;
411
412 case CVMX_HELPER_INTERFACE_MODE_SGMII:
413 priv->init = cvm_oct_sgmii_init;
385 device_set_desc(dev, "Cavium Octeon XAUI Ethernet");
386 break;
387
388 case CVMX_HELPER_INTERFACE_MODE_LOOP:
389 priv->init = cvm_oct_common_init;
390 priv->uninit = cvm_oct_common_uninit;
391 device_set_desc(dev, "Cavium Octeon LOOP Ethernet");
392 break;
393
394 case CVMX_HELPER_INTERFACE_MODE_SGMII:
395 priv->init = cvm_oct_sgmii_init;
414 priv->uninit = cvm_oct_sgmii_uninit;
396 priv->uninit = cvm_oct_common_uninit;
415 device_set_desc(dev, "Cavium Octeon SGMII Ethernet");
416 break;
417
418 case CVMX_HELPER_INTERFACE_MODE_SPI:
419 priv->init = cvm_oct_spi_init;
420 priv->uninit = cvm_oct_spi_uninit;
421 device_set_desc(dev, "Cavium Octeon SPI Ethernet");
422 break;

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

501#else
502 panic("%s: need to detach and free interface.", __func__);
503#endif
504 cvm_oct_device[port] = NULL;
505 }
506 }
507
508 cvmx_pko_shutdown();
397 device_set_desc(dev, "Cavium Octeon SGMII Ethernet");
398 break;
399
400 case CVMX_HELPER_INTERFACE_MODE_SPI:
401 priv->init = cvm_oct_spi_init;
402 priv->uninit = cvm_oct_spi_uninit;
403 device_set_desc(dev, "Cavium Octeon SPI Ethernet");
404 break;

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

483#else
484 panic("%s: need to detach and free interface.", __func__);
485#endif
486 cvm_oct_device[port] = NULL;
487 }
488 }
489
490 cvmx_pko_shutdown();
509#if 0
510 cvm_oct_proc_shutdown();
511#endif
512
513 cvmx_ipd_free_ptr();
514
515 /* Free the HW pools */
516 cvm_oct_mem_empty_fpa(CVMX_FPA_PACKET_POOL, CVMX_FPA_PACKET_POOL_SIZE, num_packet_buffers);
517 cvm_oct_mem_empty_fpa(CVMX_FPA_WQE_POOL, CVMX_FPA_WQE_POOL_SIZE, num_packet_buffers);
518 if (CVMX_FPA_OUTPUT_BUFFER_POOL != CVMX_FPA_PACKET_POOL)
519 cvm_oct_mem_empty_fpa(CVMX_FPA_OUTPUT_BUFFER_POOL, CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE, 128);
520}
491
492 cvmx_ipd_free_ptr();
493
494 /* Free the HW pools */
495 cvm_oct_mem_empty_fpa(CVMX_FPA_PACKET_POOL, CVMX_FPA_PACKET_POOL_SIZE, num_packet_buffers);
496 cvm_oct_mem_empty_fpa(CVMX_FPA_WQE_POOL, CVMX_FPA_WQE_POOL_SIZE, num_packet_buffers);
497 if (CVMX_FPA_OUTPUT_BUFFER_POOL != CVMX_FPA_PACKET_POOL)
498 cvm_oct_mem_empty_fpa(CVMX_FPA_OUTPUT_BUFFER_POOL, CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE, 128);
499}