Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(C) 2024 Marvell.
3 : : */
4 : :
5 : : #include <regex.h>
6 : :
7 : : #include <cnxk_eswitch.h>
8 : : #include <cnxk_ethdev.h>
9 : :
10 : : #ifndef __CNXK_REP_H__
11 : : #define __CNXK_REP_H__
12 : :
13 : : #define CNXK_REP_TX_OFFLOAD_CAPA \
14 : : (RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE | RTE_ETH_TX_OFFLOAD_VLAN_INSERT | \
15 : : RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
16 : :
17 : : #define CNXK_REP_RX_OFFLOAD_CAPA \
18 : : (RTE_ETH_RX_OFFLOAD_SCATTER | RTE_ETH_RX_OFFLOAD_RSS_HASH | RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
19 : :
20 : : /* Common ethdev ops */
21 : : extern struct eth_dev_ops cnxk_rep_dev_ops;
22 : :
23 : : /* Flow ops for representor ports */
24 : : extern struct rte_flow_ops cnxk_rep_flow_ops;
25 : :
26 : : struct cnxk_rep_queue_stats {
27 : : uint64_t pkts;
28 : : uint64_t bytes;
29 : : };
30 : :
31 : : struct cnxk_rep_rxq {
32 : : /* Parent rep device */
33 : : struct cnxk_rep_dev *rep_dev;
34 : : /* Queue ID */
35 : : uint16_t qid;
36 : : /* No of desc */
37 : : uint16_t nb_desc;
38 : : /* mempool handle */
39 : : struct rte_mempool *mpool;
40 : : /* RX config parameters */
41 : : const struct rte_eth_rxconf *rx_conf;
42 : : /* Per queue TX statistics */
43 : : struct cnxk_rep_queue_stats stats;
44 : : };
45 : :
46 : : struct cnxk_rep_txq {
47 : : /* Parent rep device */
48 : : struct cnxk_rep_dev *rep_dev;
49 : : /* Queue ID */
50 : : uint16_t qid;
51 : : /* No of desc */
52 : : uint16_t nb_desc;
53 : : /* TX config parameters */
54 : : const struct rte_eth_txconf *tx_conf;
55 : : /* Per queue TX statistics */
56 : : struct cnxk_rep_queue_stats stats;
57 : : };
58 : :
59 : : /* Representor port configurations */
60 : : struct cnxk_rep_dev {
61 : : uint16_t port_id;
62 : : uint16_t rep_id;
63 : : uint16_t switch_domain_id;
64 : : struct cnxk_eswitch_dev *parent_dev;
65 : : uint16_t hw_func;
66 : : bool is_vf_active;
67 : : bool native_repte;
68 : : struct cnxk_rep_rxq *rxq;
69 : : struct cnxk_rep_txq *txq;
70 : : uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
71 : : uint16_t repte_mtu;
72 : : };
73 : :
74 : : /* Inline functions */
75 : : static inline void
76 : : cnxk_rep_lock(struct cnxk_rep_dev *rep)
77 : : {
78 : : rte_spinlock_lock(&rep->parent_dev->rep_lock);
79 : : }
80 : :
81 : : static inline void
82 : : cnxk_rep_unlock(struct cnxk_rep_dev *rep)
83 : : {
84 : : rte_spinlock_unlock(&rep->parent_dev->rep_lock);
85 : : }
86 : :
87 : : static inline struct cnxk_rep_dev *
88 : : cnxk_rep_pmd_priv(const struct rte_eth_dev *eth_dev)
89 : : {
90 [ # # # # : 0 : return eth_dev->data->dev_private;
# # # # #
# # # # #
# # # # #
# # # # #
# # ]
91 : : }
92 : :
93 : : static __rte_always_inline void
94 : : cnxk_rep_pool_buffer_stats(struct rte_mempool *pool)
95 : : {
96 : : plt_rep_dbg(" pool %s size %d buffer count in use %d available %d\n", pool->name,
97 : : pool->size, rte_mempool_in_use_count(pool), rte_mempool_avail_count(pool));
98 : : }
99 : :
100 : : static inline int
101 : 0 : cnxk_ethdev_is_representor(const char *if_name)
102 : : {
103 : : regex_t regex;
104 : : int val;
105 : :
106 : 0 : val = regcomp(®ex, "net_.*_representor_.*", 0);
107 : 0 : val = regexec(®ex, if_name, 0, NULL, 0);
108 : 0 : return (val == 0);
109 : : }
110 : :
111 : : /* Prototypes */
112 : : int cnxk_rep_dev_probe(struct rte_pci_device *pci_dev, struct cnxk_eswitch_dev *eswitch_dev);
113 : : int cnxk_rep_dev_remove(struct cnxk_eswitch_dev *eswitch_dev);
114 : : int cnxk_rep_dev_uninit(struct rte_eth_dev *ethdev);
115 : : int cnxk_rep_dev_info_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *dev_info);
116 : : int cnxk_rep_representor_info_get(struct rte_eth_dev *dev, struct rte_eth_representor_info *info);
117 : : int cnxk_rep_dev_configure(struct rte_eth_dev *eth_dev);
118 : :
119 : : int cnxk_rep_link_update(struct rte_eth_dev *eth_dev, int wait_to_compl);
120 : : int cnxk_rep_dev_start(struct rte_eth_dev *eth_dev);
121 : : int cnxk_rep_rx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t queue_idx, uint16_t nb_desc,
122 : : unsigned int socket_id, const struct rte_eth_rxconf *rx_conf,
123 : : struct rte_mempool *mp);
124 : : int cnxk_rep_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t queue_idx, uint16_t nb_desc,
125 : : unsigned int socket_id, const struct rte_eth_txconf *tx_conf);
126 : : void cnxk_rep_rx_queue_release(struct rte_eth_dev *dev, uint16_t queue_idx);
127 : : void cnxk_rep_tx_queue_release(struct rte_eth_dev *dev, uint16_t queue_idx);
128 : : int cnxk_rep_dev_stop(struct rte_eth_dev *eth_dev);
129 : : int cnxk_rep_dev_close(struct rte_eth_dev *eth_dev);
130 : : int cnxk_rep_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *stats);
131 : : int cnxk_rep_stats_reset(struct rte_eth_dev *eth_dev);
132 : : int cnxk_rep_flow_ops_get(struct rte_eth_dev *ethdev, const struct rte_flow_ops **ops);
133 : : int cnxk_rep_state_update(struct cnxk_eswitch_dev *eswitch_dev, uint16_t hw_func, uint16_t *rep_id);
134 : : int cnxk_rep_promiscuous_enable(struct rte_eth_dev *ethdev);
135 : : int cnxk_rep_promiscuous_disable(struct rte_eth_dev *ethdev);
136 : : int cnxk_rep_mac_addr_set(struct rte_eth_dev *eth_dev, struct rte_ether_addr *addr);
137 : : uint16_t cnxk_rep_tx_burst_dummy(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
138 : : uint16_t cnxk_rep_rx_burst_dummy(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
139 : : void cnxk_rep_tx_queue_stop(struct rte_eth_dev *ethdev, uint16_t queue_id);
140 : : void cnxk_rep_rx_queue_stop(struct rte_eth_dev *ethdev, uint16_t queue_id);
141 : : int cnxk_rep_xstats_get(struct rte_eth_dev *eth_dev, struct rte_eth_xstat *stats, unsigned int n);
142 : : int cnxk_rep_xstats_reset(struct rte_eth_dev *eth_dev);
143 : : int cnxk_rep_xstats_get_names(struct rte_eth_dev *eth_dev, struct rte_eth_xstat_name *xstats_names,
144 : : unsigned int n);
145 : : int cnxk_rep_xstats_get_by_id(struct rte_eth_dev *eth_dev, const uint64_t *ids, uint64_t *values,
146 : : unsigned int n);
147 : : int cnxk_rep_xstats_get_names_by_id(struct rte_eth_dev *eth_dev, const uint64_t *ids,
148 : : struct rte_eth_xstat_name *xstats_names, unsigned int n);
149 : :
150 : : #endif /* __CNXK_REP_H__ */
|