Skip to content

Commit

Permalink
netdev: Sync'ed and cleaned {get, set}_config() and get_status()
Browse files Browse the repository at this point in the history
For better usability, the function pairs get_config() and
set_config() for each netdev should be symmetric: Options which are
accepted by set_config() should be returned by get_config() and the
latter should output valid options for set_config() only.

This patch moves key-value pairs which are no valid options from
get_config() to the get_status() callback. For example, get_config()
in lib/netdev-dpdk.c returned {configured,requested}_{rx,tx}_queues
previously. For requested rx queues the proper option name is n_rxq,
so requested_rx_queues has been renamed respectively. Tx queues
cannot be changed by the user, hence requested_tx_queues has been
dropped. Both configured_{rx,tx}_queues will be returned as
n_{r,t}xq in the get_status() callback.

The documentation in vswitchd/vswitch.xml for status columns has been
updated accordingly. Status columns pci-vendor_id and pci-device_id
have been replaced with bus_info in order to sync changes from [0].

[0] openvswitch@a77c779

Reported-at: https://bugzilla.redhat.com/1949855
Signed-off-by: Jakob Meng <[email protected]>
Signed-off-by: 0-day Robot <[email protected]>
  • Loading branch information
JM1 authored and ovsrobot committed Sep 27, 2023
1 parent 13dde11 commit ba82f57
Show file tree
Hide file tree
Showing 24 changed files with 311 additions and 215 deletions.
12 changes: 4 additions & 8 deletions Documentation/intro/install/afxdp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,10 @@ Otherwise, enable debugging by::
ovs-appctl vlog/set netdev_afxdp::dbg

To check which XDP mode was chosen by ``best-effort``, you can look for
``xdp-mode-in-use`` in the output of ``ovs-appctl dpctl/show``::

# ovs-appctl dpctl/show
netdev@ovs-netdev:
<...>
port 2: ens802f0 (afxdp: n_rxq=1, use-need-wakeup=true,
xdp-mode=best-effort,
xdp-mode-in-use=native-with-zerocopy)
``xdp-mode`` in the output of ``ovs-vsctl get interface INT status:xdp-mode``::

# ovs-vsctl get interface ens802f0 status:xdp-mode
"native-with-zerocopy"

References
----------
Expand Down
4 changes: 2 additions & 2 deletions Documentation/topics/dpdk/phy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Example::
a dedicated queue, it will be explicit::

$ ovs-vsctl get interface dpdk-p0 status
{..., rx_steering=unsupported}
{..., rx-steering=unsupported}

More details can often be found in ``ovs-vswitchd.log``::

Expand Down Expand Up @@ -499,7 +499,7 @@ its options::

$ ovs-appctl dpctl/show
[...]
port 3: dpdk-rep0 (dpdk: configured_rx_queues=1, ..., dpdk-vf-mac=00:11:22:33:44:55, ...)
port 3: dpdk-rep0 (dpdk: ..., dpdk-vf-mac=00:11:22:33:44:55, ...)

$ ovs-vsctl show
[...]
Expand Down
21 changes: 19 additions & 2 deletions lib/netdev-afxdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,6 @@ netdev_afxdp_get_config(const struct netdev *netdev, struct smap *args)
ovs_mutex_lock(&dev->mutex);
smap_add_format(args, "n_rxq", "%d", netdev->n_rxq);
smap_add_format(args, "xdp-mode", "%s", xdp_modes[dev->xdp_mode].name);
smap_add_format(args, "xdp-mode-in-use", "%s",
xdp_modes[dev->xdp_mode_in_use].name);
smap_add_format(args, "use-need-wakeup", "%s",
dev->use_need_wakeup ? "true" : "false");
ovs_mutex_unlock(&dev->mutex);
Expand Down Expand Up @@ -1367,3 +1365,22 @@ netdev_afxdp_get_stats(const struct netdev *netdev,

return error;
}

int
netdev_afxdp_get_status(const struct netdev *netdev,
struct smap *args)
{
int error = netdev_linux_get_status(netdev, args);
if (error) {
return error;
}

struct netdev_linux *dev = netdev_linux_cast(netdev);

ovs_mutex_lock(&dev->mutex);
smap_add_format(args, "xdp-mode", "%s",
xdp_modes[dev->xdp_mode_in_use].name);
ovs_mutex_unlock(&dev->mutex);

return error;
}
1 change: 1 addition & 0 deletions lib/netdev-afxdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ int netdev_afxdp_set_config(struct netdev *netdev, const struct smap *args,
int netdev_afxdp_get_config(const struct netdev *netdev, struct smap *args);
int netdev_afxdp_get_stats(const struct netdev *netdev_,
struct netdev_stats *stats);
int netdev_afxdp_get_status(const struct netdev *netdev, struct smap *args);
int netdev_afxdp_get_custom_stats(const struct netdev *netdev,
struct netdev_custom_stats *custom_stats);

Expand Down
49 changes: 29 additions & 20 deletions lib/netdev-dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1905,31 +1905,34 @@ netdev_dpdk_get_config(const struct netdev *netdev, struct smap *args)

ovs_mutex_lock(&dev->mutex);

smap_add_format(args, "requested_rx_queues", "%d", dev->user_n_rxq);
smap_add_format(args, "configured_rx_queues", "%d", netdev->n_rxq);
smap_add_format(args, "requested_tx_queues", "%d", dev->requested_n_txq);
smap_add_format(args, "configured_tx_queues", "%d", netdev->n_txq);
smap_add_format(args, "mtu", "%d", dev->mtu);
smap_add_format(args, "dpdk-devargs", "%s", dev->devargs);
smap_add_format(args, "n_rxq", "%d", dev->user_n_rxq);
smap_add_format(args, "rx-flow-ctrl", "%s",
dev->fc_conf.mode == RTE_ETH_FC_TX_PAUSE ||
dev->fc_conf.mode == RTE_ETH_FC_FULL ? "true" : "false");
smap_add_format(args, "tx-flow-ctrl", "%s",
dev->fc_conf.mode == RTE_ETH_FC_RX_PAUSE ||
dev->fc_conf.mode == RTE_ETH_FC_FULL ? "true" : "false");
smap_add_format(args, "flow-ctrl-autoneg", "%s",
dev->fc_conf.autoneg ? "true" : "false");

if (dev->type == DPDK_DEV_ETH) {
smap_add_format(args, "n_rxq_desc", "%d", dev->rxq_size);
smap_add_format(args, "n_txq_desc", "%d", dev->txq_size);
if (dev->hw_ol_features & NETDEV_RX_CHECKSUM_OFFLOAD) {
smap_add(args, "rx_csum_offload", "true");
} else {
smap_add(args, "rx_csum_offload", "false");
}

if (dev->rx_steer_flags == DPDK_RX_STEER_LACP) {
smap_add(args, "rx-steering", "rss+lacp");
}
smap_add(args, "lsc_interrupt_mode",

smap_add(args, "dpdk-lsc-interrupt",
dev->lsc_interrupt_mode ? "true" : "false");

if (dpdk_port_is_representor(dev)) {
smap_add_format(args, "dpdk-vf-mac", ETH_ADDR_FMT,
ETH_ADDR_ARGS(dev->requested_hwaddr));
}
}

ovs_mutex_unlock(&dev->mutex);

return 0;
Expand Down Expand Up @@ -4161,6 +4164,13 @@ netdev_dpdk_get_status(const struct netdev *netdev, struct smap *args)
smap_add_format(args, "max_vfs", "%u", dev_info.max_vfs);
smap_add_format(args, "max_vmdq_pools", "%u", dev_info.max_vmdq_pools);

smap_add_format(args, "n_rxq", "%d", netdev->n_rxq);
smap_add_format(args, "n_txq", "%d", netdev->n_txq);

smap_add(args, "rx_csum_offload",
dev->hw_ol_features & NETDEV_RX_CHECKSUM_OFFLOAD
? "true" : "false");

/* Querying the DPDK library for iftype may be done in future, pending
* support; cf. RFC 3635 Section 3.2.4. */
enum { IF_TYPE_ETHERNETCSMACD = 6 };
Expand All @@ -4186,16 +4196,15 @@ netdev_dpdk_get_status(const struct netdev *netdev, struct smap *args)
ETH_ADDR_ARGS(dev->hwaddr));
}

if (rx_steer_flags) {
if (!rx_steer_flows_num) {
smap_add(args, "rx_steering", "unsupported");
smap_add(args, "rx-steering", dev->rx_steer_flags == DPDK_RX_STEER_LACP
? "rss+lacp" : "unsupported");

if (rx_steer_flags && rx_steer_flows_num) {
smap_add_format(args, "rx_steering_queue", "%d", n_rxq - 1);
if (n_rxq > 2) {
smap_add_format(args, "rss_queues", "0-%d", n_rxq - 2);
} else {
smap_add_format(args, "rx_steering_queue", "%d", n_rxq - 1);
if (n_rxq > 2) {
smap_add_format(args, "rss_queues", "0-%d", n_rxq - 2);
} else {
smap_add(args, "rss_queues", "0");
}
smap_add(args, "rss_queues", "0");
}
}

Expand Down
17 changes: 13 additions & 4 deletions lib/netdev-dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,14 +795,23 @@ netdev_dummy_get_config(const struct netdev *dev, struct smap *args)

dummy_packet_conn_get_config(&netdev->conn, args);

/* pcap, rxq_pcap and tx_pcap cannot be recovered because filenames have
* been discarded after opening file descriptors */

smap_add_format(args, "ol_ip_csum_set_good", "%s",
netdev->ol_ip_csum_set_good ? "true" : "false");

smap_add_format(args, "ol_ip_csum", "%s",
netdev->ol_ip_csum ? "true" : "false");

/* 'dummy-pmd' specific config. */
if (!netdev_is_pmd(dev)) {
goto exit;
}
smap_add_format(args, "requested_rx_queues", "%d", netdev->requested_n_rxq);
smap_add_format(args, "configured_rx_queues", "%d", dev->n_rxq);
smap_add_format(args, "requested_tx_queues", "%d", netdev->requested_n_txq);
smap_add_format(args, "configured_tx_queues", "%d", dev->n_txq);

smap_add_format(args, "n_rxq", "%d", netdev->requested_n_rxq);
smap_add_format(args, "n_txq", "%d", netdev->requested_n_txq);
smap_add_format(args, "numa_id", "%d", netdev->requested_numa_id);

exit:
ovs_mutex_unlock(&netdev->mutex);
Expand Down
2 changes: 2 additions & 0 deletions lib/netdev-linux-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ void netdev_linux_run(const struct netdev_class *);
int get_stats_via_netlink(const struct netdev *netdev_,
struct netdev_stats *stats);

int netdev_linux_get_status(const struct netdev *netdev_, struct smap *smap);

struct netdev_linux {
struct netdev up;

Expand Down
4 changes: 2 additions & 2 deletions lib/netdev-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -3493,7 +3493,7 @@ netdev_linux_get_next_hop(const struct in_addr *host, struct in_addr *next_hop,
return ENXIO;
}

static int
int
netdev_linux_get_status(const struct netdev *netdev_, struct smap *smap)
{
struct netdev_linux *netdev = netdev_linux_cast(netdev_);
Expand Down Expand Up @@ -3759,7 +3759,7 @@ const struct netdev_class netdev_internal_class = {
.destruct = netdev_afxdp_destruct, \
.get_stats = netdev_afxdp_get_stats, \
.get_custom_stats = netdev_afxdp_get_custom_stats, \
.get_status = netdev_linux_get_status, \
.get_status = netdev_afxdp_get_status, \
.set_config = netdev_afxdp_set_config, \
.get_config = netdev_afxdp_get_config, \
.reconfigure = netdev_afxdp_reconfigure, \
Expand Down
14 changes: 7 additions & 7 deletions tests/bridge.at
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ add_of_ports br0 1 2
AT_CHECK([ovs-appctl dpif/show], [0], [dnl
dummy@ovs-dummy: hit:0 missed:0
br0:
br0 65534/100: (dummy-internal)
p1 1/1: (dummy)
p2 2/2: (dummy)
br0 65534/100: (dummy-internal: ol_ip_csum=false, ol_ip_csum_set_good=false)
p1 1/1: (dummy: ol_ip_csum=false, ol_ip_csum_set_good=false)
p2 2/2: (dummy: ol_ip_csum=false, ol_ip_csum_set_good=false)
])

# Delete p1 from the datapath with "ovs-dpctl del-if"
Expand All @@ -23,17 +23,17 @@ AT_CHECK([ovs-appctl dpctl/del-if dummy@ovs-dummy p1])
AT_CHECK([ovs-appctl dpif/show], [0], [dnl
dummy@ovs-dummy: hit:0 missed:0
br0:
br0 65534/100: (dummy-internal)
p2 2/2: (dummy)
br0 65534/100: (dummy-internal: ol_ip_csum=false, ol_ip_csum_set_good=false)
p2 2/2: (dummy: ol_ip_csum=false, ol_ip_csum_set_good=false)
])

# Force reconfiguration and make sure that p1 got added back.
AT_CHECK([ovs-vsctl del-port p2])
AT_CHECK([ovs-appctl dpif/show], [0], [dnl
dummy@ovs-dummy: hit:0 missed:0
br0:
br0 65534/100: (dummy-internal)
p1 1/1: (dummy)
br0 65534/100: (dummy-internal: ol_ip_csum=false, ol_ip_csum_set_good=false)
p1 1/1: (dummy: ol_ip_csum=false, ol_ip_csum_set_good=false)
])
OVS_APP_EXIT_AND_WAIT([ovs-vswitchd])
OVS_APP_EXIT_AND_WAIT([ovsdb-server])
Expand Down
12 changes: 6 additions & 6 deletions tests/dpctl.at
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ AT_CHECK([ovs-appctl dpctl/show dummy@br0], [0], [dnl
dummy@br0:
lookups: hit:0 missed:0 lost:0
flows: 0
port 0: br0 (dummy-internal)
port 0: br0 (dummy-internal: ol_ip_csum=false, ol_ip_csum_set_good=false)
])
AT_CHECK([ovs-appctl dpctl/add-if dummy@br0 vif1.0,type=dummy,port_no=5])
AT_CHECK([ovs-appctl dpctl/show dummy@br0], [0], [dnl
dummy@br0:
lookups: hit:0 missed:0 lost:0
flows: 0
port 0: br0 (dummy-internal)
port 5: vif1.0 (dummy)
port 0: br0 (dummy-internal: ol_ip_csum=false, ol_ip_csum_set_good=false)
port 5: vif1.0 (dummy: ol_ip_csum=false, ol_ip_csum_set_good=false)
])
AT_CHECK([ovs-appctl dpctl/add-if dummy@br0 vif1.0,type=dummy], [2], [],
[stderr])
Expand All @@ -54,7 +54,7 @@ AT_CHECK([ovs-appctl dpctl/show dummy@br0], [0], [dnl
dummy@br0:
lookups: hit:0 missed:0 lost:0
flows: 0
port 0: br0 (dummy-internal)
port 0: br0 (dummy-internal: ol_ip_csum=false, ol_ip_csum_set_good=false)
])
AT_CHECK([ovs-appctl dpctl/del-if dummy@br0 vif1.0], [2], [],
[ovs-vswitchd: no port named vif1.0
Expand All @@ -64,7 +64,7 @@ AT_CHECK([ovs-appctl dpctl/show dummy@br0], [0], [dnl
dummy@br0:
lookups: hit:0 missed:0 lost:0
flows: 0
port 0: br0 (dummy-internal)
port 0: br0 (dummy-internal: ol_ip_csum=false, ol_ip_csum_set_good=false)
])
AT_CHECK([ovs-appctl dpctl/del-if dummy@br0 nonexistent], [2], [],
[ovs-vswitchd: no port named nonexistent
Expand Down Expand Up @@ -150,4 +150,4 @@ ovs-appctl: ovs-vswitchd: server returned an error
])
AT_CHECK([ovs-appctl dpctl/ct-del-limits zone=])
OVS_VSWITCHD_STOP
AT_CLEANUP
AT_CLEANUP
6 changes: 3 additions & 3 deletions tests/mcast-snooping.at
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ AT_CHECK([
AT_CHECK([ovs-appctl dpif/show], [0], [dnl
dummy@ovs-dummy: hit:0 missed:0
br0:
br0 65534/100: (dummy-internal)
p1 1/1: (dummy)
p2 2/2: (dummy)
br0 65534/100: (dummy-internal: ol_ip_csum=false, ol_ip_csum_set_good=false)
p1 1/1: (dummy: ol_ip_csum=false, ol_ip_csum_set_good=false)
p2 2/2: (dummy: ol_ip_csum=false, ol_ip_csum_set_good=false)
])

ovs-appctl time/stop
Expand Down
34 changes: 17 additions & 17 deletions tests/mpls-xlate.at
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ OVS_VSWITCHD_START(
AT_CHECK([ovs-appctl dpif/show], [0], [dnl
dummy@ovs-dummy: hit:0 missed:0
br0:
br0 65534/100: (dummy-internal)
p0 1/1: (dummy)
br0 65534/100: (dummy-internal: ol_ip_csum=false, ol_ip_csum_set_good=false)
p0 1/1: (dummy: ol_ip_csum=false, ol_ip_csum_set_good=false)
p1 2/none: (patch: peer=p2)
br1:
br1 65534/101: (dummy-internal)
br1 65534/101: (dummy-internal: ol_ip_csum=false, ol_ip_csum_set_good=false)
p2 1/none: (patch: peer=p1)
])

Expand Down Expand Up @@ -163,13 +163,13 @@ AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg ofproto_dpif_upcall:dbg])
AT_CHECK([ovs-appctl dpif/show], [0], [dnl
dummy@ovs-dummy: hit:0 missed:0
br0:
br0 65534/100: (dummy-internal)
p0 1/1: (dummy)
br0 65534/100: (dummy-internal: ol_ip_csum=false, ol_ip_csum_set_good=false)
p0 1/1: (dummy: ol_ip_csum=false, ol_ip_csum_set_good=false)
p1 2/none: (patch: peer=p2)
br1:
br1 65534/101: (dummy-internal)
br1 65534/101: (dummy-internal: ol_ip_csum=false, ol_ip_csum_set_good=false)
p2 1/none: (patch: peer=p1)
p3 3/3: (dummy)
p3 3/3: (dummy: ol_ip_csum=false, ol_ip_csum_set_good=false)
])

dnl MPLS PUSH + POP.
Expand Down Expand Up @@ -225,13 +225,13 @@ OVS_VSWITCHD_START(
AT_CHECK([ovs-appctl dpif/show], [0], [dnl
dummy@ovs-dummy: hit:0 missed:0
br0:
br0 65534/100: (dummy-internal)
p1 1/1: (dummy)
br0 65534/100: (dummy-internal: ol_ip_csum=false, ol_ip_csum_set_good=false)
p1 1/1: (dummy: ol_ip_csum=false, ol_ip_csum_set_good=false)
p2 2/none: (patch: peer=p3)
br1:
br1 65534/101: (dummy-internal)
br1 65534/101: (dummy-internal: ol_ip_csum=false, ol_ip_csum_set_good=false)
p3 3/none: (patch: peer=p2)
p4 4/4: (dummy)
p4 4/4: (dummy: ol_ip_csum=false, ol_ip_csum_set_good=false)
])

AT_CHECK([ovs-ofctl del-flows br0])
Expand Down Expand Up @@ -276,9 +276,9 @@ OVS_VSWITCHD_START([dnl
AT_CHECK([ovs-appctl dpif/show], [0], [dnl
dummy@ovs-dummy: hit:0 missed:0
br0:
br0 65534/100: (dummy-internal)
p1 1/1: (dummy)
p2 2/2: (dummy)
br0 65534/100: (dummy-internal: ol_ip_csum=false, ol_ip_csum_set_good=false)
p1 1/1: (dummy: ol_ip_csum=false, ol_ip_csum_set_good=false)
p2 2/2: (dummy: ol_ip_csum=false, ol_ip_csum_set_good=false)
])

AT_CHECK([ovs-ofctl del-flows br0])
Expand Down Expand Up @@ -307,9 +307,9 @@ OVS_VSWITCHD_START([dnl
AT_CHECK([ovs-appctl dpif/show], [0], [dnl
dummy@ovs-dummy: hit:0 missed:0
br0:
br0 65534/100: (dummy-internal)
p1 1/1: (dummy)
p2 2/2: (dummy)
br0 65534/100: (dummy-internal: ol_ip_csum=false, ol_ip_csum_set_good=false)
p1 1/1: (dummy: ol_ip_csum=false, ol_ip_csum_set_good=false)
p2 2/2: (dummy: ol_ip_csum=false, ol_ip_csum_set_good=false)
])

AT_CHECK([ovs-ofctl del-flows br0])
Expand Down
4 changes: 2 additions & 2 deletions tests/netdev-type.at
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ add_of_ports br0 1
AT_CHECK([ovs-appctl dpif/show], [0], [dnl
dummy@ovs-dummy: hit:0 missed:0
br0:
br0 65534/100: (dummy-internal)
p1 1/1: (dummy)
br0 65534/100: (dummy-internal: ol_ip_csum=false, ol_ip_csum_set_good=false)
p1 1/1: (dummy: ol_ip_csum=false, ol_ip_csum_set_good=false)
])
#
# Set MAC address of dummy device and check that it has been set
Expand Down
Loading

0 comments on commit ba82f57

Please sign in to comment.