aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-01-05 01:52:38 +0100
committerDamjan Marion <damarion@cisco.com>2022-01-05 19:04:07 +0100
commitd4f88cc0967ea1de66396ac07b20cf6e33a3fa1a (patch)
tree1f316431b414ac3adf693eb876132dd675c73a2a /src/plugins
parent7c11bd7a87b901106bb14d40572fddc703b74e5b (diff)
interface: refactor interface capabilities code
Make it shorter to type, easier to debug, make adding callbacks in future simpler. Type: improvement Change-Id: I6cdd6375e36da23bd452a7c7273ff42789e94433 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/af_xdp/device.c5
-rw-r--r--src/plugins/avf/device.c13
-rw-r--r--src/plugins/dpdk/device/common.c4
-rw-r--r--src/plugins/dpdk/device/init.c18
-rw-r--r--src/plugins/lldp/lldp_cli.c4
-rw-r--r--src/plugins/memif/memif.c4
-rw-r--r--src/plugins/rdma/device.c5
-rw-r--r--src/plugins/vmxnet3/vmxnet3.c7
8 files changed, 26 insertions, 34 deletions
diff --git a/src/plugins/af_xdp/device.c b/src/plugins/af_xdp/device.c
index d27901b70b3..c45e873f662 100644
--- a/src/plugins/af_xdp/device.c
+++ b/src/plugins/af_xdp/device.c
@@ -508,7 +508,6 @@ af_xdp_create_if (vlib_main_t * vm, af_xdp_create_if_args_t * args)
af_xdp_main_t *am = &af_xdp_main;
af_xdp_device_t *ad;
vnet_sw_interface_t *sw;
- vnet_hw_interface_t *hw;
int rxq_num, txq_num, q_num;
int ns_fds[2];
int i, ret;
@@ -658,9 +657,9 @@ af_xdp_create_if (vlib_main_t * vm, af_xdp_create_if_args_t * args)
}
sw = vnet_get_hw_sw_interface (vnm, ad->hw_if_index);
- hw = vnet_get_hw_interface (vnm, ad->hw_if_index);
args->sw_if_index = ad->sw_if_index = sw->sw_if_index;
- hw->caps |= VNET_HW_INTERFACE_CAP_SUPPORTS_INT_MODE;
+
+ vnet_hw_if_set_caps (vnm, ad->hw_if_index, VNET_HW_IF_CAP_INT_MODE);
vnet_hw_if_set_input_node (vnm, ad->hw_if_index, af_xdp_input_node.index);
diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c
index cc2415a9293..627ead6f4e5 100644
--- a/src/plugins/avf/device.c
+++ b/src/plugins/avf/device.c
@@ -1729,22 +1729,19 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args)
if (error)
goto error;
- /* Indicate ability to support L3 DMAC filtering and
- * initialize interface to L3 non-promisc mode */
- vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, ad->hw_if_index);
- hi->caps |= VNET_HW_INTERFACE_CAP_SUPPORTS_MAC_FILTER |
- VNET_HW_INTERFACE_CAP_SUPPORTS_L4_TX_CKSUM |
- VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_GSO;
ethernet_set_flags (vnm, ad->hw_if_index,
ETHERNET_INTERFACE_FLAG_DEFAULT_L3);
vnet_sw_interface_t *sw = vnet_get_hw_sw_interface (vnm, ad->hw_if_index);
args->sw_if_index = ad->sw_if_index = sw->sw_if_index;
- vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, ad->hw_if_index);
- hw->caps |= VNET_HW_INTERFACE_CAP_SUPPORTS_INT_MODE;
vnet_hw_if_set_input_node (vnm, ad->hw_if_index, avf_input_node.index);
+ /* set hw interface caps */
+ vnet_hw_if_set_caps (vnm, ad->hw_if_index,
+ VNET_HW_IF_CAP_INT_MODE | VNET_HW_IF_CAP_MAC_FILTER |
+ VNET_HW_IF_CAP_L4_TX_CKSUM | VNET_HW_IF_CAP_TCP_GSO);
+
for (i = 0; i < ad->n_rx_queues; i++)
{
u32 qi, fi;
diff --git a/src/plugins/dpdk/device/common.c b/src/plugins/dpdk/device/common.c
index ce91df59868..b0aaaaf9d47 100644
--- a/src/plugins/dpdk/device/common.c
+++ b/src/plugins/dpdk/device/common.c
@@ -212,7 +212,7 @@ dpdk_setup_interrupts (dpdk_device_t *xd)
if (xd->flags & DPDK_DEVICE_FLAG_INT_SUPPORTED)
{
- hi->caps |= VNET_HW_INTERFACE_CAP_SUPPORTS_INT_MODE;
+ hi->caps |= VNET_HW_IF_CAP_INT_MODE;
for (int q = 0; q < xd->conf.n_rx_queues; q++)
{
dpdk_rx_queue_t *rxq = vec_elt_at_index (xd->rx_queues, q);
@@ -221,7 +221,7 @@ dpdk_setup_interrupts (dpdk_device_t *xd)
if (rxq->efd < 0)
{
xd->flags &= ~DPDK_DEVICE_FLAG_INT_SUPPORTED;
- hi->caps &= ~VNET_HW_INTERFACE_CAP_SUPPORTS_INT_MODE;
+ hi->caps &= ~VNET_HW_IF_CAP_INT_MODE;
break;
}
f.read_function = dpdk_rx_read_ready;
diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c
index e2c919428f2..80d85a856de 100644
--- a/src/plugins/dpdk/device/init.c
+++ b/src/plugins/dpdk/device/init.c
@@ -801,7 +801,7 @@ 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_INTERFACE_CAP_SUPPORTS_MAC_FILTER;
+ hi->caps |= VNET_HW_IF_CAP_MAC_FILTER;
ethernet_set_flags (vnm, xd->hw_if_index,
ETHERNET_INTERFACE_FLAG_DEFAULT_L3);
}
@@ -809,22 +809,22 @@ dpdk_lib_init (dpdk_main_t * dm)
if (xd->conf.no_tx_checksum_offload == 0)
if (xd->flags & DPDK_DEVICE_FLAG_TX_OFFLOAD && hi != NULL)
{
- hi->caps |= VNET_HW_INTERFACE_CAP_SUPPORTS_TX_IP4_CKSUM |
- VNET_HW_INTERFACE_CAP_SUPPORTS_TX_TCP_CKSUM |
- VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_CKSUM;
+ 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_INTERFACE_CAP_SUPPORTS_TX_IP4_OUTER_CKSUM |
- VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_OUTER_CKSUM;
+ 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_INTERFACE_CAP_SUPPORTS_TX_CKSUM))
+ (hi->caps & VNET_HW_IF_CAP_TX_CKSUM))
{
- hi->caps |= VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_GSO;
+ 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 &&
@@ -832,7 +832,7 @@ dpdk_lib_init (dpdk_main_t * dm)
{
xd->port_conf.txmode.offloads |=
DEV_TX_OFFLOAD_VXLAN_TNL_TSO;
- hi->caps |= VNET_HW_INTERFACE_CAP_SUPPORTS_VXLAN_TNL_GSO;
+ hi->caps |= VNET_HW_IF_CAP_VXLAN_TNL_GSO;
}
}
else
diff --git a/src/plugins/lldp/lldp_cli.c b/src/plugins/lldp/lldp_cli.c
index 84757977d83..317595ff6a5 100644
--- a/src/plugins/lldp/lldp_cli.c
+++ b/src/plugins/lldp/lldp_cli.c
@@ -103,7 +103,7 @@ lldp_cfg_intf_set (u32 hw_if_index, u8 ** port_desc, u8 ** mgmt_ip4,
}
/* Add MAC address to an interface's filter */
- if (hi->caps & VNET_HW_INTERFACE_CAP_SUPPORTS_MAC_FILTER)
+ if (hi->caps & VNET_HW_IF_CAP_MAC_FILTER)
{
error =
vnet_hw_interface_add_del_mac_address (lm->vnet_main,
@@ -130,7 +130,7 @@ lldp_cfg_intf_set (u32 hw_if_index, u8 ** port_desc, u8 ** mgmt_ip4,
lldp_intf_t *n = lldp_get_intf (lm, hi->sw_if_index);
lldp_delete_intf (lm, n);
/* Remove MAC address from the interface's filter */
- if ((n) && (hi->caps & VNET_HW_INTERFACE_CAP_SUPPORTS_MAC_FILTER))
+ if ((n) && (hi->caps & VNET_HW_IF_CAP_MAC_FILTER))
{
error =
vnet_hw_interface_add_del_mac_address (lm->vnet_main,
diff --git a/src/plugins/memif/memif.c b/src/plugins/memif/memif.c
index 2d5866a9d0d..d7b82ceee5e 100644
--- a/src/plugins/memif/memif.c
+++ b/src/plugins/memif/memif.c
@@ -902,7 +902,6 @@ memif_create_if (vlib_main_t * vm, memif_create_if_args_t * args)
clib_error_t *error = 0;
int ret = 0;
uword *p;
- vnet_hw_interface_t *hw;
memif_socket_file_t *msf = 0;
int rv = 0;
@@ -1090,8 +1089,7 @@ memif_create_if (vlib_main_t * vm, memif_create_if_args_t * args)
mif->flags |= MEMIF_IF_FLAG_ZERO_COPY;
}
- hw = vnet_get_hw_interface (vnm, mif->hw_if_index);
- hw->caps |= VNET_HW_INTERFACE_CAP_SUPPORTS_INT_MODE;
+ vnet_hw_if_set_caps (vnm, mif->hw_if_index, VNET_HW_IF_CAP_INT_MODE);
vnet_hw_if_set_input_node (vnm, mif->hw_if_index, memif_input_node.index);
mhash_set (&msf->dev_instance_by_id, &mif->id, mif->dev_instance, 0);
diff --git a/src/plugins/rdma/device.c b/src/plugins/rdma/device.c
index 1198d99b14e..3ea8e44b3e7 100644
--- a/src/plugins/rdma/device.c
+++ b/src/plugins/rdma/device.c
@@ -362,8 +362,7 @@ rdma_register_interface (vnet_main_t * vnm, rdma_device_t * rd)
/* Indicate ability to support L3 DMAC filtering and
* initialize interface to L3 non-promisc mode */
- vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, rd->hw_if_index);
- hi->caps |= VNET_HW_INTERFACE_CAP_SUPPORTS_MAC_FILTER;
+ vnet_hw_if_set_caps (vnm, rd->hw_if_index, VNET_HW_IF_CAP_MAC_FILTER);
ethernet_set_flags (vnm, rd->hw_if_index,
ETHERNET_INTERFACE_FLAG_DEFAULT_L3);
return err;
@@ -1022,7 +1021,7 @@ are explicitly disabled, and if the interface supports it.*/
/*
* FIXME: add support for interrupt mode
* vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, rd->hw_if_index);
- * hw->caps |= VNET_HW_INTERFACE_CAP_SUPPORTS_INT_MODE;
+ * hw->caps |= VNET_HW_IF_CAP_INT_MODE;
*/
vnet_hw_if_set_input_node (vnm, rd->hw_if_index, rdma_input_node.index);
diff --git a/src/plugins/vmxnet3/vmxnet3.c b/src/plugins/vmxnet3/vmxnet3.c
index 16d7d86fb3a..8059d03c595 100644
--- a/src/plugins/vmxnet3/vmxnet3.c
+++ b/src/plugins/vmxnet3/vmxnet3.c
@@ -818,12 +818,11 @@ vmxnet3_create_if (vlib_main_t * vm, vmxnet3_create_if_args_t * args)
args->sw_if_index = sw->sw_if_index;
vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, vd->hw_if_index);
- hw->caps |= VNET_HW_INTERFACE_CAP_SUPPORTS_INT_MODE;
+ hw->caps |= VNET_HW_IF_CAP_INT_MODE;
if (vd->gso_enable)
{
- hw->caps |= (VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_GSO |
- VNET_HW_INTERFACE_CAP_SUPPORTS_TX_TCP_CKSUM |
- VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_CKSUM);
+ hw->caps |= (VNET_HW_IF_CAP_TCP_GSO | VNET_HW_IF_CAP_TX_TCP_CKSUM |
+ VNET_HW_IF_CAP_TX_UDP_CKSUM);
}
vnet_hw_if_set_input_node (vnm, vd->hw_if_index, vmxnet3_input_node.index);