27f6556dd9d8be56f1314bb45ce591d6d2b77799
[dpdk.git] / drivers / net / octeontx / octeontx_ethdev.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Cavium, Inc
3  */
4
5 #ifndef __OCTEONTX_ETHDEV_H__
6 #define __OCTEONTX_ETHDEV_H__
7
8 #include <stdbool.h>
9
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>
15
16 #include <octeontx_fpavf.h>
17
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"
23
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
28
29 #define OCTEONTX_MAX_BGX_PORTS                  4
30 #define OCTEONTX_MAX_LMAC_PER_BGX               4
31
32 #define OCCTX_RX_NB_SEG_MAX                     6
33
34 /* VLAN tag inserted by OCCTX_TX_VTAG_ACTION.
35  * In Tx space is always reserved for this in FRS.
36  */
37 #define OCCTX_MAX_VTAG_INS              2
38 #define OCCTX_MAX_VTAG_ACT_SIZE         (4 * OCCTX_MAX_VTAG_INS)
39
40 /* HW config of frame size doesn't include FCS */
41 #define OCCTX_MAX_HW_FRS                9212
42 #define OCCTX_MIN_HW_FRS                60
43
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)
47
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)
51
52 #define OCCTX_MIN_FRS           (OCCTX_MIN_HW_FRS + RTE_ETHER_CRC_LEN)
53
54 #define OCCTX_MAX_MTU           (OCCTX_MAX_FRS - OCCTX_L2_OVERHEAD)
55
56 #define OCTEONTX_RX_OFFLOADS            (DEV_RX_OFFLOAD_CHECKSUM     | \
57                                          DEV_RX_OFFLOAD_SCATTER      | \
58                                          DEV_RX_OFFLOAD_JUMBO_FRAME)
59
60 #define OCTEONTX_TX_OFFLOADS            (DEV_TX_OFFLOAD_MT_LOCKFREE    |  \
61                                          DEV_TX_OFFLOAD_MBUF_FAST_FREE |  \
62                                          DEV_TX_OFFLOAD_MULTI_SEGS)
63
64 static inline struct octeontx_nic *
65 octeontx_pmd_priv(struct rte_eth_dev *dev)
66 {
67         return dev->data->dev_private;
68 }
69
70 extern uint16_t
71 rte_octeontx_pchan_map[OCTEONTX_MAX_BGX_PORTS][OCTEONTX_MAX_LMAC_PER_BGX];
72
73 /* Octeontx ethdev nic */
74 struct octeontx_nic {
75         struct rte_eth_dev *dev;
76         int node;
77         int port_id;
78         int port_ena;
79         int base_ichan;
80         int num_ichans;
81         int base_ochan;
82         int num_ochans;
83         uint8_t evdev;
84         uint8_t bpen;
85         uint8_t fcs_strip;
86         uint8_t bcast_mode;
87         uint8_t mcast_mode;
88         uint16_t num_tx_queues;
89         uint64_t hwcap;
90         uint8_t pko_vfid;
91         uint8_t link_up;
92         uint8_t duplex;
93         uint8_t speed;
94         uint16_t bgx_mtu;
95         uint16_t mtu;
96         uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
97         /* Rx port parameters */
98         struct {
99                 bool classifier_enable;
100                 bool hash_enable;
101                 bool initialized;
102         } pki;
103
104         uint16_t ev_queues;
105         uint16_t ev_ports;
106         uint64_t rx_offloads;
107         uint16_t rx_offload_flags;
108         uint64_t tx_offloads;
109         uint16_t tx_offload_flags;
110 } __rte_cache_aligned;
111
112 struct octeontx_txq {
113         uint16_t queue_id;
114         octeontx_dq_t dq;
115         struct rte_eth_dev *eth_dev;
116 } __rte_cache_aligned;
117
118 struct octeontx_rxq {
119         uint16_t queue_id;
120         uint16_t port_id;
121         uint8_t evdev;
122         struct rte_eth_dev *eth_dev;
123         uint16_t ev_queues;
124         uint16_t ev_ports;
125         struct rte_mempool *pool;
126 } __rte_cache_aligned;
127
128 void
129 octeontx_set_tx_function(struct rte_eth_dev *dev);
130 #endif /* __OCTEONTX_ETHDEV_H__ */