Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright 2018-2019 NXP 3 : : */ 4 : : 5 : : #ifndef _ENETC_H_ 6 : : #define _ENETC_H_ 7 : : 8 : : #include <rte_time.h> 9 : : 10 : : #include "base/enetc_hw.h" 11 : : 12 : : #define PCI_VENDOR_ID_FREESCALE 0x1957 13 : : 14 : : /* Max TX rings per ENETC. */ 15 : : #define MAX_TX_RINGS 2 16 : : 17 : : /* Max RX rings per ENTEC. */ 18 : : #define MAX_RX_RINGS 1 19 : : 20 : : /* Max BD counts per Ring. */ 21 : : #define MAX_BD_COUNT 64000 22 : : /* Min BD counts per Ring. */ 23 : : #define MIN_BD_COUNT 32 24 : : /* BD ALIGN */ 25 : : #define BD_ALIGN 8 26 : : 27 : : /* minimum frame size supported */ 28 : : #define ENETC_MAC_MINFRM_SIZE 68 29 : : /* maximum frame size supported */ 30 : : #define ENETC_MAC_MAXFRM_SIZE 9600 31 : : 32 : : /* The max frame size with default MTU */ 33 : : #define ENETC_ETH_MAX_LEN (RTE_ETHER_MTU + \ 34 : : RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN) 35 : : 36 : : /* 37 : : * upper_32_bits - return bits 32-63 of a number 38 : : * @n: the number we're accessing 39 : : * 40 : : * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress 41 : : * the "right shift count >= width of type" warning when that quantity is 42 : : * 32-bits. 43 : : */ 44 : : #define upper_32_bits(n) ((uint32_t)(((n) >> 16) >> 16)) 45 : : 46 : : /* 47 : : * lower_32_bits - return bits 0-31 of a number 48 : : * @n: the number we're accessing 49 : : */ 50 : : #define lower_32_bits(n) ((uint32_t)(n)) 51 : : 52 : : #define ENETC_TXBD(BDR, i) (&(((struct enetc_tx_bd *)((BDR).bd_base))[i])) 53 : : #define ENETC_RXBD(BDR, i) (&(((union enetc_rx_bd *)((BDR).bd_base))[i])) 54 : : 55 : : struct enetc_swbd { 56 : : struct rte_mbuf *buffer_addr; 57 : : }; 58 : : 59 : : struct enetc_bdr { 60 : : void *bd_base; /* points to Rx or Tx BD ring */ 61 : : struct enetc_swbd *q_swbd; 62 : : union { 63 : : void *tcir; 64 : : void *rcir; 65 : : }; 66 : : int bd_count; /* # of BDs */ 67 : : int next_to_use; 68 : : int next_to_clean; 69 : : uint16_t index; 70 : : uint8_t crc_len; /* 0 if CRC stripped, 4 otherwise */ 71 : : union { 72 : : void *tcisr; /* Tx */ 73 : : int next_to_alloc; /* Rx */ 74 : : }; 75 : : struct rte_mempool *mb_pool; /* mbuf pool to populate RX ring. */ 76 : : struct rte_eth_dev *ndev; 77 : : }; 78 : : 79 : : /* 80 : : * Structure to store private data for each driver instance (for each port). 81 : : */ 82 : : struct enetc_eth_adapter { 83 : : struct rte_eth_dev *ndev; 84 : : struct enetc_eth_hw hw; 85 : : }; 86 : : 87 : : #define ENETC_DEV_PRIVATE(adapter) \ 88 : : ((struct enetc_eth_adapter *)adapter) 89 : : 90 : : #define ENETC_DEV_PRIVATE_TO_HW(adapter) \ 91 : : (&((struct enetc_eth_adapter *)adapter)->hw) 92 : : 93 : : #define ENETC_DEV_PRIVATE_TO_STATS(adapter) \ 94 : : (&((struct enetc_eth_adapter *)adapter)->stats) 95 : : 96 : : #define ENETC_DEV_PRIVATE_TO_INTR(adapter) \ 97 : : (&((struct enetc_eth_adapter *)adapter)->intr) 98 : : 99 : : /* 100 : : * RX/TX ENETC function prototypes 101 : : */ 102 : : uint16_t enetc_xmit_pkts(void *txq, struct rte_mbuf **tx_pkts, 103 : : uint16_t nb_pkts); 104 : : uint16_t enetc_recv_pkts(void *rxq, struct rte_mbuf **rx_pkts, 105 : : uint16_t nb_pkts); 106 : : 107 : : 108 : : int enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt); 109 : : 110 : : static inline int 111 : : enetc_bd_unused(struct enetc_bdr *bdr) 112 : : { 113 [ # # # # ]: 0 : if (bdr->next_to_clean > bdr->next_to_use) 114 : 0 : return bdr->next_to_clean - bdr->next_to_use - 1; 115 : : 116 : 0 : return bdr->bd_count + bdr->next_to_clean - bdr->next_to_use - 1; 117 : : } 118 : : #endif /* _ENETC_H_ */