ethernet.c (226024) | ethernet.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: --- 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 226024 2011-10-04 20:17:43Z marcel $"); | 30__FBSDID("$FreeBSD: head/sys/mips/cavium/octe/ethernet.c 231987 2012-02-22 01:30:25Z gonzo $"); |
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> --- 53 unchanged lines hidden (view full) --- 92 */ 93static struct taskqueue *cvm_oct_link_taskq; 94 95/* 96 * Number of buffers in output buffer pool. 97 */ 98static int cvm_oct_num_output_buffers; 99 | 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> --- 53 unchanged lines hidden (view full) --- 92 */ 93static struct taskqueue *cvm_oct_link_taskq; 94 95/* 96 * Number of buffers in output buffer pool. 97 */ 98static int cvm_oct_num_output_buffers; 99 |
100/* 101 * The offset from mac_addr_base that should be used for the next port 102 * that is configured. By convention, if any mgmt ports exist on the 103 * chip, they get the first mac addresses. The ports controlled by 104 * this driver are numbered sequencially following any mgmt addresses 105 * that may exist. 106 */ 107unsigned int cvm_oct_mac_addr_offset; 108 | |
109/** 110 * Function to update link status. 111 */ 112static void cvm_oct_update_link(void *context, int pending) 113{ 114 cvm_oct_private_t *priv = (cvm_oct_private_t *)context; 115 struct ifnet *ifp = priv->ifp; 116 cvmx_helper_link_info_t link_info; --- 199 unchanged lines hidden (view full) --- 316 int ifnum; 317 int num_interfaces; 318 int interface; 319 int fau = FAU_NUM_PACKET_BUFFERS_TO_FREE; 320 int qos; 321 322 printf("cavium-ethernet: %s\n", OCTEON_SDK_VERSION_STRING); 323 | 100/** 101 * Function to update link status. 102 */ 103static void cvm_oct_update_link(void *context, int pending) 104{ 105 cvm_oct_private_t *priv = (cvm_oct_private_t *)context; 106 struct ifnet *ifp = priv->ifp; 107 cvmx_helper_link_info_t link_info; --- 199 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 |
324 /* 325 * MAC addresses for this driver start after the management 326 * ports. 327 * 328 * XXX Would be nice if __cvmx_mgmt_port_num_ports() were 329 * not static to cvmx-mgmt-port.c. 330 */ 331 if (OCTEON_IS_MODEL(OCTEON_CN56XX)) 332 cvm_oct_mac_addr_offset = 1; 333 else if (OCTEON_IS_MODEL(OCTEON_CN52XX) || OCTEON_IS_MODEL(OCTEON_CN63XX)) 334 cvm_oct_mac_addr_offset = 2; 335 else 336 cvm_oct_mac_addr_offset = 0; 337 | |
338 cvm_oct_rx_initialize(); 339 cvm_oct_configure_common_hw(bus); 340 341 cvmx_helper_initialize_packet_io_global(); 342 343 /* Change the input group for all ports before input is enabled */ 344 num_interfaces = cvmx_helper_get_number_of_interfaces(); 345 for (interface = 0; interface < num_interfaces; interface++) { --- 24 unchanged lines hidden (view full) --- 370 371 ifnum = 0; 372 num_interfaces = cvmx_helper_get_number_of_interfaces(); 373 for (interface = 0; interface < num_interfaces; interface++) { 374 cvmx_helper_interface_mode_t imode = cvmx_helper_interface_get_mode(interface); 375 int num_ports = cvmx_helper_ports_on_interface(interface); 376 int port; 377 | 315 cvm_oct_rx_initialize(); 316 cvm_oct_configure_common_hw(bus); 317 318 cvmx_helper_initialize_packet_io_global(); 319 320 /* Change the input group for all ports before input is enabled */ 321 num_interfaces = cvmx_helper_get_number_of_interfaces(); 322 for (interface = 0; interface < num_interfaces; interface++) { --- 24 unchanged lines hidden (view full) --- 347 348 ifnum = 0; 349 num_interfaces = cvmx_helper_get_number_of_interfaces(); 350 for (interface = 0; interface < num_interfaces; interface++) { 351 cvmx_helper_interface_mode_t imode = cvmx_helper_interface_get_mode(interface); 352 int num_ports = cvmx_helper_ports_on_interface(interface); 353 int port; 354 |
378 for (port = cvmx_helper_get_ipd_port(interface, 0); port < cvmx_helper_get_ipd_port(interface, num_ports); port++) { | 355 for (port = cvmx_helper_get_ipd_port(interface, 0); 356 port < cvmx_helper_get_ipd_port(interface, num_ports); 357 ifnum++, port++) { |
379 cvm_oct_private_t *priv; 380 struct ifnet *ifp; 381 | 358 cvm_oct_private_t *priv; 359 struct ifnet *ifp; 360 |
382 dev = BUS_ADD_CHILD(bus, 0, "octe", ifnum++); | 361 dev = BUS_ADD_CHILD(bus, 0, "octe", ifnum); |
383 if (dev != NULL) 384 ifp = if_alloc(IFT_ETHER); 385 if (dev == NULL || ifp == NULL) { | 362 if (dev != NULL) 363 ifp = if_alloc(IFT_ETHER); 364 if (dev == NULL || ifp == NULL) { |
386 printf("\t\tFailed to allocate ethernet device for port %d\n", port); | 365 printf("Failed to allocate ethernet device for interface %d port %d\n", interface, port); |
387 continue; 388 } 389 390 /* Initialize the device private structure. */ 391 device_probe(dev); 392 priv = device_get_softc(dev); 393 priv->dev = dev; 394 priv->ifp = ifp; --- 54 unchanged lines hidden (view full) --- 449 priv->uninit = cvm_oct_rgmii_uninit; 450 device_set_desc(dev, "Cavium Octeon GMII Ethernet"); 451 break; 452 } 453 454 ifp->if_softc = priv; 455 456 if (!priv->init) { | 366 continue; 367 } 368 369 /* Initialize the device private structure. */ 370 device_probe(dev); 371 priv = device_get_softc(dev); 372 priv->dev = dev; 373 priv->ifp = ifp; --- 54 unchanged lines hidden (view full) --- 428 priv->uninit = cvm_oct_rgmii_uninit; 429 device_set_desc(dev, "Cavium Octeon GMII Ethernet"); 430 break; 431 } 432 433 ifp->if_softc = priv; 434 435 if (!priv->init) { |
457 panic("%s: unsupported device type, need to free ifp.", __func__); 458 } else 459 if (priv->init(ifp) < 0) { 460 printf("\t\tFailed to register ethernet device for interface %d, port %d\n", 461 interface, priv->port); 462 panic("%s: init failed, need to free ifp.", __func__); | 436 printf("octe%d: unsupported device type interface %d, port %d\n", 437 ifnum, interface, priv->port); 438 if_free(ifp); 439 } else if (priv->init(ifp) != 0) { 440 printf("octe%d: failed to register device for interface %d, port %d\n", 441 ifnum, interface, priv->port); 442 if_free(ifp); |
463 } else { 464 cvm_oct_device[priv->port] = ifp; 465 fau -= cvmx_pko_get_num_queues(priv->port) * sizeof(uint32_t); 466 } 467 } 468 } 469 470 if (INTERRUPT_LIMIT) { --- 61 unchanged lines hidden --- | 443 } else { 444 cvm_oct_device[priv->port] = ifp; 445 fau -= cvmx_pko_get_num_queues(priv->port) * sizeof(uint32_t); 446 } 447 } 448 } 449 450 if (INTERRUPT_LIMIT) { --- 61 unchanged lines hidden --- |