1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Cavium, Inc
5 #ifndef __OCTEONTX_ETHDEV_H__
6 #define __OCTEONTX_ETHDEV_H__
10 #include <rte_common.h>
11 #include <rte_ethdev_driver.h>
12 #include <rte_eventdev.h>
13 #include <rte_mempool.h>
14 #include <rte_memory.h>
16 #include <octeontx_fpavf.h>
18 #include "base/octeontx_bgx.h"
19 #include "base/octeontx_pki_var.h"
20 #include "base/octeontx_pkivf.h"
21 #include "base/octeontx_pkovf.h"
22 #include "base/octeontx_io.h"
24 #define OCTEONTX_PMD net_octeontx
25 #define OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT 12
26 #define OCTEONTX_VDEV_NR_PORT_ARG ("nr_port")
27 #define OCTEONTX_MAX_NAME_LEN 32
29 #define OCTEONTX_MAX_BGX_PORTS 4
30 #define OCTEONTX_MAX_LMAC_PER_BGX 4
32 #define OCCTX_RX_NB_SEG_MAX 6
33 #define OCCTX_INTR_POLL_INTERVAL_MS 1000
34 /* VLAN tag inserted by OCCTX_TX_VTAG_ACTION.
35 * In Tx space is always reserved for this in FRS.
37 #define OCCTX_MAX_VTAG_INS 2
38 #define OCCTX_MAX_VTAG_ACT_SIZE (4 * OCCTX_MAX_VTAG_INS)
40 /* HW config of frame size doesn't include FCS */
41 #define OCCTX_MAX_HW_FRS 9212
42 #define OCCTX_MIN_HW_FRS 60
44 /* ETH_HLEN+ETH_FCS+2*VLAN_HLEN */
45 #define OCCTX_L2_OVERHEAD (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + \
46 OCCTX_MAX_VTAG_ACT_SIZE)
48 /* Since HW FRS includes NPC VTAG insertion space, user has reduced FRS */
49 #define OCCTX_MAX_FRS \
50 (OCCTX_MAX_HW_FRS + RTE_ETHER_CRC_LEN - OCCTX_MAX_VTAG_ACT_SIZE)
52 #define OCCTX_MIN_FRS (OCCTX_MIN_HW_FRS + RTE_ETHER_CRC_LEN)
54 #define OCCTX_MAX_MTU (OCCTX_MAX_FRS - OCCTX_L2_OVERHEAD)
56 #define OCTEONTX_RX_OFFLOADS ( \
57 DEV_RX_OFFLOAD_CHECKSUM | \
58 DEV_RX_OFFLOAD_SCTP_CKSUM | \
59 DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM | \
60 DEV_RX_OFFLOAD_SCATTER | \
61 DEV_RX_OFFLOAD_SCATTER | \
62 DEV_RX_OFFLOAD_JUMBO_FRAME | \
63 DEV_RX_OFFLOAD_VLAN_FILTER)
65 #define OCTEONTX_TX_OFFLOADS ( \
66 DEV_TX_OFFLOAD_MBUF_FAST_FREE | \
67 DEV_TX_OFFLOAD_MT_LOCKFREE | \
68 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM | \
69 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM | \
70 DEV_TX_OFFLOAD_IPV4_CKSUM | \
71 DEV_TX_OFFLOAD_TCP_CKSUM | \
72 DEV_TX_OFFLOAD_UDP_CKSUM | \
73 DEV_TX_OFFLOAD_SCTP_CKSUM | \
74 DEV_TX_OFFLOAD_MULTI_SEGS)
76 static inline struct octeontx_nic *
77 octeontx_pmd_priv(struct rte_eth_dev *dev)
79 return dev->data->dev_private;
83 rte_octeontx_pchan_map[OCTEONTX_MAX_BGX_PORTS][OCTEONTX_MAX_LMAC_PER_BGX];
86 TAILQ_ENTRY(vlan_entry) next;
90 TAILQ_HEAD(octeontx_vlan_filter_tbl, vlan_entry);
92 struct octeontx_vlan_info {
93 struct octeontx_vlan_filter_tbl fltr_tbl;
97 struct octeontx_fc_info {
98 enum rte_eth_fc_mode mode; /**< Link flow control mode */
99 enum rte_eth_fc_mode def_mode;
102 uint16_t def_highmark;
103 uint16_t def_lowmark;
107 /* Octeontx ethdev nic */
108 struct octeontx_nic {
109 struct rte_eth_dev *dev;
122 uint16_t num_tx_queues;
130 uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
131 /* Rx port parameters */
133 bool classifier_enable;
140 uint64_t rx_offloads;
141 uint16_t rx_offload_flags;
142 uint64_t tx_offloads;
143 uint16_t tx_offload_flags;
144 struct octeontx_vlan_info vlan_info;
146 struct octeontx_fc_info fc;
147 } __rte_cache_aligned;
149 struct octeontx_txq {
152 struct rte_eth_dev *eth_dev;
153 } __rte_cache_aligned;
155 struct octeontx_rxq {
159 struct rte_eth_dev *eth_dev;
162 struct rte_mempool *pool;
163 } __rte_cache_aligned;
166 octeontx_set_tx_function(struct rte_eth_dev *dev);
169 int octeontx_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx);
170 int octeontx_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx);
171 int octeontx_dev_vlan_offload_init(struct rte_eth_dev *dev);
172 int octeontx_dev_vlan_offload_fini(struct rte_eth_dev *eth_dev);
173 int octeontx_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask);
174 int octeontx_dev_vlan_filter_set(struct rte_eth_dev *dev,
175 uint16_t vlan_id, int on);
176 int octeontx_dev_set_link_up(struct rte_eth_dev *eth_dev);
177 int octeontx_dev_set_link_down(struct rte_eth_dev *eth_dev);
180 int octeontx_dev_flow_ctrl_init(struct rte_eth_dev *dev);
181 int octeontx_dev_flow_ctrl_fini(struct rte_eth_dev *dev);
182 int octeontx_dev_flow_ctrl_get(struct rte_eth_dev *dev,
183 struct rte_eth_fc_conf *fc_conf);
184 int octeontx_dev_flow_ctrl_set(struct rte_eth_dev *dev,
185 struct rte_eth_fc_conf *fc_conf);
187 #endif /* __OCTEONTX_ETHDEV_H__ */