| 1 | /***********************license start*********************************** |
| 2 | * Copyright (c) 2003-2017 Cavium Inc. ([email protected]). All rights |
| 3 | * reserved. |
| 4 | * |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are |
| 8 | * met: |
| 9 | * |
| 10 | * * Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * |
| 13 | * * Redistributions in binary form must reproduce the above |
| 14 | * copyright notice, this list of conditions and the following |
| 15 | * disclaimer in the documentation and/or other materials provided |
| 16 | * with the distribution. |
| 17 | * |
| 18 | * * Neither the name of Cavium Inc. nor the names of |
| 19 | * its contributors may be used to endorse or promote products |
| 20 | * derived from this software without specific prior written |
| 21 | * permission. |
| 22 | * |
| 23 | * This Software, including technical data, may be subject to U.S. export |
| 24 | * control laws, including the U.S. Export Administration Act and its |
| 25 | * associated regulations, and may be subject to export or import |
| 26 | * regulations in other countries. |
| 27 | * |
| 28 | * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
| 29 | * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR |
| 30 | * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT |
| 31 | * TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY |
| 32 | * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT |
| 33 | * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES |
| 34 | * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR |
| 35 | * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, |
| 36 | * QUIET POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK |
| 37 | * ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU. |
| 38 | ***********************license end**************************************/ |
| 39 | |
| 40 | /** |
| 41 | * @file |
| 42 | * |
| 43 | * Interface to the NIC. |
| 44 | * |
| 45 | * @addtogroup hal |
| 46 | * @{ |
| 47 | */ |
| 48 | |
| 49 | typedef enum |
| 50 | { |
| 51 | BDK_NIC_TYPE_BGX, /* All chips */ |
| 52 | BDK_NIC_TYPE_TNS, /* Only allowed on CN88XX */ |
| 53 | BDK_NIC_TYPE_LBK, /* CN81XX and CN83XX */ |
| 54 | BDK_NIC_TYPE_RGMII, /* CN83XX */ |
| 55 | } bdk_nic_type_t; |
| 56 | |
| 57 | /** |
| 58 | * Configure NIC for a specific port. This is called for each |
| 59 | * port on every interface that connects to NIC. |
| 60 | * |
| 61 | * @param handle Handle for port to config |
| 62 | * @param ntype Type of LMAC this NIC connects to |
| 63 | * @param lmac_credits |
| 64 | * Size of the LMAC buffer in bytes. Used to configure the number of credits to |
| 65 | * setup between the NIC and LMAC |
| 66 | * |
| 67 | * @return Zero on success, negative on failure |
| 68 | */ |
| 69 | extern int bdk_nic_port_init(bdk_if_handle_t handle, bdk_nic_type_t ntype, int lmac_credits); |
| 70 | |
| 71 | /** |
| 72 | * Get the current TX queue depth. Note that this operation may be slow |
| 73 | * and adversly affect packet IO performance. |
| 74 | * |
| 75 | * @param handle Port to check |
| 76 | * |
| 77 | * @return Depth of the queue in packets |
| 78 | */ |
| 79 | extern int bdk_nic_get_queue_depth(bdk_if_handle_t handle); |
| 80 | |
| 81 | /** |
| 82 | * Send a packet |
| 83 | * |
| 84 | * @param handle Handle of port to send on |
| 85 | * @param packet Packet to send |
| 86 | * |
| 87 | * @return Zero on success, negative on failure |
| 88 | */ |
| 89 | extern int bdk_nic_transmit(bdk_if_handle_t handle, const bdk_if_packet_t *packet); |
| 90 | |
| 91 | /** |
| 92 | * Query NIC and fill in the transmit stats for the supplied |
| 93 | * interface handle. |
| 94 | * |
| 95 | * @param handle Port handle |
| 96 | */ |
| 97 | extern void bdk_nic_fill_tx_stats(bdk_if_handle_t handle); |
| 98 | |
| 99 | /** |
| 100 | * Query NIC and fill in the receive stats for the supplied |
| 101 | * interface handle. |
| 102 | * |
| 103 | * @param handle Port handle |
| 104 | */ |
| 105 | extern void bdk_nic_fill_rx_stats(bdk_if_handle_t handle); |
| 106 | |
| 107 | /** @} */ |