net/txgbe: support getting device info
[dpdk.git] / drivers / net / txgbe / txgbe_rxtx.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2020
3  */
4
5 #include <sys/queue.h>
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10
11 #include <rte_common.h>
12 #include <rte_ethdev.h>
13
14 #include "txgbe_logs.h"
15 #include "base/txgbe.h"
16 #include "txgbe_ethdev.h"
17 #include "txgbe_rxtx.h"
18
19 static int
20 txgbe_is_vf(struct rte_eth_dev *dev)
21 {
22         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
23
24         switch (hw->mac.type) {
25         case txgbe_mac_raptor_vf:
26                 return 1;
27         default:
28                 return 0;
29         }
30 }
31
32 uint64_t
33 txgbe_get_rx_queue_offloads(struct rte_eth_dev *dev __rte_unused)
34 {
35         return DEV_RX_OFFLOAD_VLAN_STRIP;
36 }
37
38 uint64_t
39 txgbe_get_rx_port_offloads(struct rte_eth_dev *dev)
40 {
41         uint64_t offloads;
42         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
43         struct rte_eth_dev_sriov *sriov = &RTE_ETH_DEV_SRIOV(dev);
44
45         offloads = DEV_RX_OFFLOAD_IPV4_CKSUM  |
46                    DEV_RX_OFFLOAD_UDP_CKSUM   |
47                    DEV_RX_OFFLOAD_TCP_CKSUM   |
48                    DEV_RX_OFFLOAD_KEEP_CRC    |
49                    DEV_RX_OFFLOAD_JUMBO_FRAME |
50                    DEV_RX_OFFLOAD_VLAN_FILTER |
51                    DEV_RX_OFFLOAD_RSS_HASH |
52                    DEV_RX_OFFLOAD_SCATTER;
53
54         if (!txgbe_is_vf(dev))
55                 offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
56                              DEV_RX_OFFLOAD_QINQ_STRIP |
57                              DEV_RX_OFFLOAD_VLAN_EXTEND);
58
59         /*
60          * RSC is only supported by PF devices in a non-SR-IOV
61          * mode.
62          */
63         if (hw->mac.type == txgbe_mac_raptor && !sriov->active)
64                 offloads |= DEV_RX_OFFLOAD_TCP_LRO;
65
66         if (hw->mac.type == txgbe_mac_raptor)
67                 offloads |= DEV_RX_OFFLOAD_MACSEC_STRIP;
68
69         offloads |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
70
71         return offloads;
72 }
73
74 uint64_t
75 txgbe_get_tx_queue_offloads(struct rte_eth_dev *dev)
76 {
77         RTE_SET_USED(dev);
78
79         return 0;
80 }
81
82 uint64_t
83 txgbe_get_tx_port_offloads(struct rte_eth_dev *dev)
84 {
85         uint64_t tx_offload_capa;
86
87         tx_offload_capa =
88                 DEV_TX_OFFLOAD_VLAN_INSERT |
89                 DEV_TX_OFFLOAD_IPV4_CKSUM  |
90                 DEV_TX_OFFLOAD_UDP_CKSUM   |
91                 DEV_TX_OFFLOAD_TCP_CKSUM   |
92                 DEV_TX_OFFLOAD_SCTP_CKSUM  |
93                 DEV_TX_OFFLOAD_TCP_TSO     |
94                 DEV_TX_OFFLOAD_UDP_TSO     |
95                 DEV_TX_OFFLOAD_UDP_TNL_TSO      |
96                 DEV_TX_OFFLOAD_IP_TNL_TSO       |
97                 DEV_TX_OFFLOAD_VXLAN_TNL_TSO    |
98                 DEV_TX_OFFLOAD_GRE_TNL_TSO      |
99                 DEV_TX_OFFLOAD_IPIP_TNL_TSO     |
100                 DEV_TX_OFFLOAD_GENEVE_TNL_TSO   |
101                 DEV_TX_OFFLOAD_MULTI_SEGS;
102
103         if (!txgbe_is_vf(dev))
104                 tx_offload_capa |= DEV_TX_OFFLOAD_QINQ_INSERT;
105
106         tx_offload_capa |= DEV_TX_OFFLOAD_MACSEC_INSERT;
107
108         tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
109
110         return tx_offload_capa;
111 }
112