net/cnxk: support meter action to flow create
[dpdk.git] / drivers / net / cnxk / cn9k_tx.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 Marvell.
3  */
4
5 #include "cn9k_ethdev.h"
6 #include "cn9k_tx.h"
7
8 #define T(name, f6, f5, f4, f3, f2, f1, f0, sz, flags)                         \
9         uint16_t __rte_noinline __rte_hot cn9k_nix_xmit_pkts_##name(           \
10                 void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t pkts)      \
11         {                                                                      \
12                 uint64_t cmd[sz];                                              \
13                                                                                \
14                 /* For TSO inner checksum is a must */                         \
15                 if (((flags) & NIX_TX_OFFLOAD_TSO_F) &&                        \
16                     !((flags) & NIX_TX_OFFLOAD_L3_L4_CSUM_F))                  \
17                         return 0;                                              \
18                 return cn9k_nix_xmit_pkts(tx_queue, tx_pkts, pkts, cmd, flags);\
19         }
20
21 NIX_TX_FASTPATH_MODES
22 #undef T
23
24 static inline void
25 pick_tx_func(struct rte_eth_dev *eth_dev,
26              const eth_tx_burst_t tx_burst[2][2][2][2][2][2][2])
27 {
28         struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
29
30         /* [TS] [TSO] [NOFF] [VLAN] [OL3_OL4_CSUM] [IL3_IL4_CSUM] */
31         eth_dev->tx_pkt_burst = tx_burst
32                 [!!(dev->tx_offload_flags & NIX_TX_OFFLOAD_SECURITY_F)]
33                 [!!(dev->tx_offload_flags & NIX_TX_OFFLOAD_TSTAMP_F)]
34                 [!!(dev->tx_offload_flags & NIX_TX_OFFLOAD_TSO_F)]
35                 [!!(dev->tx_offload_flags & NIX_TX_OFFLOAD_MBUF_NOFF_F)]
36                 [!!(dev->tx_offload_flags & NIX_TX_OFFLOAD_VLAN_QINQ_F)]
37                 [!!(dev->tx_offload_flags & NIX_TX_OFFLOAD_OL3_OL4_CSUM_F)]
38                 [!!(dev->tx_offload_flags & NIX_TX_OFFLOAD_L3_L4_CSUM_F)];
39 }
40
41 void
42 cn9k_eth_set_tx_function(struct rte_eth_dev *eth_dev)
43 {
44         struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
45
46         const eth_tx_burst_t nix_eth_tx_burst[2][2][2][2][2][2][2] = {
47 #define T(name, f6, f5, f4, f3, f2, f1, f0, sz, flags)                         \
48         [f6][f5][f4][f3][f2][f1][f0] = cn9k_nix_xmit_pkts_##name,
49
50                 NIX_TX_FASTPATH_MODES
51 #undef T
52         };
53
54         const eth_tx_burst_t nix_eth_tx_burst_mseg[2][2][2][2][2][2][2] = {
55 #define T(name, f6, f5, f4, f3, f2, f1, f0, sz, flags)                         \
56         [f6][f5][f4][f3][f2][f1][f0] = cn9k_nix_xmit_pkts_mseg_##name,
57
58                 NIX_TX_FASTPATH_MODES
59 #undef T
60         };
61
62         const eth_tx_burst_t nix_eth_tx_vec_burst[2][2][2][2][2][2][2] = {
63 #define T(name, f6, f5, f4, f3, f2, f1, f0, sz, flags)                         \
64         [f6][f5][f4][f3][f2][f1][f0] = cn9k_nix_xmit_pkts_vec_##name,
65
66                 NIX_TX_FASTPATH_MODES
67 #undef T
68         };
69
70         const eth_tx_burst_t nix_eth_tx_vec_burst_mseg[2][2][2][2][2][2][2] = {
71 #define T(name, f6, f5, f4, f3, f2, f1, f0, sz, flags)                         \
72         [f6][f5][f4][f3][f2][f1][f0] = cn9k_nix_xmit_pkts_vec_mseg_##name,
73
74                 NIX_TX_FASTPATH_MODES
75 #undef T
76         };
77
78         if (dev->scalar_ena) {
79                 pick_tx_func(eth_dev, nix_eth_tx_burst);
80                 if (dev->tx_offloads & DEV_TX_OFFLOAD_MULTI_SEGS)
81                         pick_tx_func(eth_dev, nix_eth_tx_burst_mseg);
82         } else {
83                 pick_tx_func(eth_dev, nix_eth_tx_vec_burst);
84                 if (dev->tx_offloads & DEV_TX_OFFLOAD_MULTI_SEGS)
85                         pick_tx_func(eth_dev, nix_eth_tx_vec_burst_mseg);
86         }
87
88         rte_mb();
89 }