aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-01-09 13:02:12 +0100
committerFlorin Coras <florin.coras@gmail.com>2022-01-09 20:32:54 +0000
commit26ea3ede43b9eb157a97850c70be3016040bd025 (patch)
tree5ff69a9a17c4864ddfc0fa1f0616978461f2cdae /src
parent71635fda0dcbbb21ec3eb7af9618eb51513b8ab8 (diff)
dpdk: interface capabilities cleanup
Type: improvement Change-Id: If5636d4376fb06da62f947c28b18c07b6ad21722 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/dpdk/device/common.c53
-rw-r--r--src/plugins/dpdk/device/dpdk.h4
-rw-r--r--src/plugins/dpdk/device/format.c4
-rw-r--r--src/plugins/dpdk/device/init.c17
4 files changed, 54 insertions, 24 deletions
diff --git a/src/plugins/dpdk/device/common.c b/src/plugins/dpdk/device/common.c
index c32382a55c6..8313a293fe6 100644
--- a/src/plugins/dpdk/device/common.c
+++ b/src/plugins/dpdk/device/common.c
@@ -29,6 +29,21 @@
#include <dpdk/device/dpdk_priv.h>
#include <vppinfra/error.h>
+/* DPDK TX offload to vnet hw interface caps mapppings */
+static struct
+{
+ u64 offload;
+ vnet_hw_if_caps_t caps;
+} tx_off_caps_map[] = {
+ { DEV_TX_OFFLOAD_IPV4_CKSUM, VNET_HW_IF_CAP_TX_IP4_CKSUM },
+ { DEV_TX_OFFLOAD_TCP_CKSUM, VNET_HW_IF_CAP_TX_TCP_CKSUM },
+ { DEV_TX_OFFLOAD_UDP_CKSUM, VNET_HW_IF_CAP_TX_UDP_CKSUM },
+ { DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM, VNET_HW_IF_CAP_TX_IP4_OUTER_CKSUM },
+ { DEV_TX_OFFLOAD_OUTER_UDP_CKSUM, VNET_HW_IF_CAP_TX_UDP_OUTER_CKSUM },
+ { DEV_TX_OFFLOAD_TCP_TSO, VNET_HW_IF_CAP_TCP_GSO },
+ { DEV_TX_OFFLOAD_VXLAN_TNL_TSO, VNET_HW_IF_CAP_VXLAN_TNL_GSO }
+};
+
void
dpdk_device_error (dpdk_device_t * xd, char *str, int rv)
{
@@ -46,8 +61,10 @@ dpdk_device_setup (dpdk_device_t * xd)
vlib_thread_main_t *tm = vlib_get_thread_main ();
vnet_sw_interface_t *sw = vnet_get_sw_interface (vnm, xd->sw_if_index);
vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, xd->hw_if_index);
+ vnet_hw_if_caps_change_t caps = {};
struct rte_eth_dev_info dev_info;
u64 bitmap;
+ u64 rxo, txo;
u16 mtu;
int rv;
int j;
@@ -90,7 +107,10 @@ dpdk_device_setup (dpdk_device_t * xd)
xd->port_conf.rxmode.offloads ^= bitmap;
}
- if (xd->port_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME)
+ rxo = xd->port_conf.rxmode.offloads;
+ txo = xd->port_conf.txmode.offloads;
+
+ if (rxo & DEV_RX_OFFLOAD_JUMBO_FRAME)
xd->port_conf.rxmode.max_rx_pkt_len =
clib_min (ETHERNET_MAX_PACKET_BYTES, dev_info.max_rx_pktlen);
else
@@ -169,12 +189,29 @@ dpdk_device_setup (dpdk_device_t * xd)
xd->buffer_flags =
(VLIB_BUFFER_TOTAL_LENGTH_VALID | VLIB_BUFFER_EXT_HDR_VALID);
- if ((xd->port_conf.rxmode.offloads &
- (DEV_RX_OFFLOAD_TCP_CKSUM | DEV_RX_OFFLOAD_UDP_CKSUM)) ==
+ if ((rxo & (DEV_RX_OFFLOAD_TCP_CKSUM | DEV_RX_OFFLOAD_UDP_CKSUM)) ==
(DEV_RX_OFFLOAD_TCP_CKSUM | DEV_RX_OFFLOAD_UDP_CKSUM))
xd->buffer_flags |=
(VNET_BUFFER_F_L4_CHECKSUM_COMPUTED | VNET_BUFFER_F_L4_CHECKSUM_CORRECT);
+ /* unconditionally set mac filtering cap */
+ caps.val = caps.mask = VNET_HW_IF_CAP_MAC_FILTER;
+
+ ethernet_set_flags (vnm, xd->hw_if_index,
+ ETHERNET_INTERFACE_FLAG_DEFAULT_L3);
+
+ for (int i = 0; i < ARRAY_LEN (tx_off_caps_map); i++)
+ {
+ __typeof__ (tx_off_caps_map[0]) *v = tx_off_caps_map + i;
+ caps.mask |= v->caps;
+ if ((v->offload & txo) == v->offload)
+ caps.val |= v->caps;
+ }
+
+ vnet_hw_if_change_caps (vnm, xd->hw_if_index, &caps);
+ xd->enabled_rx_off = rxo;
+ xd->enabled_tx_off = txo;
+
if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP)
dpdk_device_start (xd);
@@ -213,6 +250,7 @@ dpdk_setup_interrupts (dpdk_device_t *xd)
{
vnet_main_t *vnm = vnet_get_main ();
vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, xd->hw_if_index);
+ int int_mode = 0;
if (!hi)
return;
@@ -236,7 +274,7 @@ dpdk_setup_interrupts (dpdk_device_t *xd)
if (xd->flags & DPDK_DEVICE_FLAG_INT_SUPPORTED)
{
- hi->caps |= VNET_HW_IF_CAP_INT_MODE;
+ int_mode = 1;
for (int q = 0; q < xd->conf.n_rx_queues; q++)
{
dpdk_rx_queue_t *rxq = vec_elt_at_index (xd->rx_queues, q);
@@ -245,7 +283,7 @@ dpdk_setup_interrupts (dpdk_device_t *xd)
if (rxq->efd < 0)
{
xd->flags &= ~DPDK_DEVICE_FLAG_INT_SUPPORTED;
- hi->caps &= ~VNET_HW_IF_CAP_INT_MODE;
+ int_mode = 0;
break;
}
f.read_function = dpdk_rx_read_ready;
@@ -266,6 +304,11 @@ dpdk_setup_interrupts (dpdk_device_t *xd)
}
}
}
+
+ if (int_mode)
+ vnet_hw_if_set_caps (vnm, hi->hw_if_index, VNET_HW_IF_CAP_INT_MODE);
+ else
+ vnet_hw_if_unset_caps (vnm, hi->hw_if_index, VNET_HW_IF_CAP_INT_MODE);
vnet_hw_if_update_runtime_data (vnm, xd->hw_if_index);
}
diff --git a/src/plugins/dpdk/device/dpdk.h b/src/plugins/dpdk/device/dpdk.h
index 4981d250ea6..f400f4887cf 100644
--- a/src/plugins/dpdk/device/dpdk.h
+++ b/src/plugins/dpdk/device/dpdk.h
@@ -212,8 +212,10 @@ typedef struct
dpdk_pmd_t pmd:8;
i8 cpu_socket;
- CLIB_CACHE_LINE_ALIGN_MARK (cacheline1);
+ CLIB_CACHE_LINE_ALIGN_MARK (cacheline1);
+ u64 enabled_tx_off;
+ u64 enabled_rx_off;
u8 *name;
u8 *interface_name_suffix;
diff --git a/src/plugins/dpdk/device/format.c b/src/plugins/dpdk/device/format.c
index efb2216f225..46a1f371312 100644
--- a/src/plugins/dpdk/device/format.c
+++ b/src/plugins/dpdk/device/format.c
@@ -583,11 +583,11 @@ format_dpdk_device (u8 * s, va_list * args)
s = format (s, "%Urx offload avail: %U\n", format_white_space, indent + 2,
format_dpdk_rx_offload_caps, di.rx_offload_capa);
s = format (s, "%Urx offload active: %U\n", format_white_space, indent + 2,
- format_dpdk_rx_offload_caps, xd->port_conf.rxmode.offloads);
+ format_dpdk_rx_offload_caps, xd->enabled_rx_off);
s = format (s, "%Utx offload avail: %U\n", format_white_space, indent + 2,
format_dpdk_tx_offload_caps, di.tx_offload_capa);
s = format (s, "%Utx offload active: %U\n", format_white_space, indent + 2,
- format_dpdk_tx_offload_caps, xd->port_conf.txmode.offloads);
+ format_dpdk_tx_offload_caps, xd->enabled_tx_off);
s = format (s,
"%Urss avail: %U\n"
"%Urss active: %U\n",
diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c
index 71c3bfac75e..19f5a545dcd 100644
--- a/src/plugins/dpdk/device/init.c
+++ b/src/plugins/dpdk/device/init.c
@@ -688,30 +688,16 @@ dpdk_lib_init (dpdk_main_t * dm)
/* Indicate ability to support L3 DMAC filtering and
* initialize interface to L3 non-promisc mode */
- hi->caps |= VNET_HW_IF_CAP_MAC_FILTER;
ethernet_set_flags (vnm, xd->hw_if_index,
ETHERNET_INTERFACE_FLAG_DEFAULT_L3);
}
- if (xd->conf.no_tx_checksum_offload == 0)
- if (xd->flags & DPDK_DEVICE_FLAG_TX_OFFLOAD && hi != NULL)
- {
- hi->caps |= VNET_HW_IF_CAP_TX_IP4_CKSUM |
- VNET_HW_IF_CAP_TX_TCP_CKSUM |
- VNET_HW_IF_CAP_TX_UDP_CKSUM;
- if (xd->conf.enable_outer_checksum_offload)
- {
- hi->caps |= VNET_HW_IF_CAP_TX_IP4_OUTER_CKSUM |
- VNET_HW_IF_CAP_TX_UDP_OUTER_CKSUM;
- }
- }
if (devconf->tso == DPDK_DEVICE_TSO_ON && hi != NULL)
{
/*tcp_udp checksum must be enabled*/
if ((xd->conf.enable_tcp_udp_checksum) &&
- (hi->caps & VNET_HW_IF_CAP_TX_CKSUM))
+ (xd->flags & DPDK_DEVICE_FLAG_TX_OFFLOAD))
{
- hi->caps |= VNET_HW_IF_CAP_TCP_GSO;
xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_TCP_TSO;
if (xd->conf.enable_outer_checksum_offload &&
@@ -719,7 +705,6 @@ dpdk_lib_init (dpdk_main_t * dm)
{
xd->port_conf.txmode.offloads |=
DEV_TX_OFFLOAD_VXLAN_TNL_TSO;
- hi->caps |= VNET_HW_IF_CAP_VXLAN_TNL_GSO;
}
}
else