1 /* SPDX-License-Identifier: BSD-3-Clause
10 #include "base/enetc_hw.h"
12 #define PCI_VENDOR_ID_FREESCALE 0x1957
14 /* Max TX rings per ENETC. */
15 #define MAX_TX_RINGS 2
17 /* Max RX rings per ENTEC. */
18 #define MAX_RX_RINGS 1
21 * upper_32_bits - return bits 32-63 of a number
22 * @n: the number we're accessing
24 * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress
25 * the "right shift count >= width of type" warning when that quantity is
28 #define upper_32_bits(n) ((uint32_t)(((n) >> 16) >> 16))
31 * lower_32_bits - return bits 0-31 of a number
32 * @n: the number we're accessing
34 #define lower_32_bits(n) ((uint32_t)(n))
36 #define ENETC_TXBD(BDR, i) (&(((struct enetc_tx_bd *)((BDR).bd_base))[i]))
37 #define ENETC_RXBD(BDR, i) (&(((union enetc_rx_bd *)((BDR).bd_base))[i]))
40 struct rte_mbuf *buffer_addr;
44 struct rte_eth_dev *ndev;
45 struct rte_mempool *mb_pool; /* mbuf pool to populate RX ring. */
46 void *bd_base; /* points to Rx or Tx BD ring */
52 int bd_count; /* # of BDs */
55 struct enetc_swbd *q_swbd;
58 int next_to_alloc; /* Rx */
63 * Structure to store private data for each driver instance (for each port).
65 struct enetc_eth_adapter {
66 struct rte_eth_dev *ndev;
67 struct enetc_eth_hw hw;
70 #define ENETC_DEV_PRIVATE(adapter) \
71 ((struct enetc_eth_adapter *)adapter)
73 #define ENETC_DEV_PRIVATE_TO_HW(adapter) \
74 (&((struct enetc_eth_adapter *)adapter)->hw)
76 #define ENETC_DEV_PRIVATE_TO_STATS(adapter) \
77 (&((struct enetc_eth_adapter *)adapter)->stats)
79 #define ENETC_DEV_PRIVATE_TO_INTR(adapter) \
80 (&((struct enetc_eth_adapter *)adapter)->intr)
82 #define ENETC_GET_HW_ADDR(reg, addr) ((void *)(((size_t)reg) + (addr)))
83 #define ENETC_REG_READ(addr) (*(uint32_t *)addr)
84 #define ENETC_REG_WRITE(addr, val) (*(uint32_t *)addr = val)
85 #define ENETC_REG_WRITE_RELAXED(addr, val) (*(uint32_t *)addr = val)
87 #endif /* _ENETC_H_ */