Skip to content

Commit

Permalink
netdev-afxdp: Sync and clean {get, set}_config() callbacks.
Browse files Browse the repository at this point in the history
For better usability, the function pairs get_config() and
set_config() for netdevs 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
also moves key-value pairs which are not valid options from get_config()
to the get_status() callback.

The documentation in vswitchd/vswitch.xml for status columns has been
updated accordingly.

Reported-at: https://bugzilla.redhat.com/1949855
Signed-off-by: Jakob Meng <code@jakobmeng.de>
Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
  • Loading branch information
JM1 authored and kevintraynor committed Nov 14, 2023
1 parent 169c6b2 commit d614f28
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 12 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
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
1 change: 1 addition & 0 deletions lib/netdev-linux-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct netdev_rxq_linux {
};

int netdev_linux_construct(struct netdev *);
int netdev_linux_get_status(const struct netdev *, struct smap *);
void netdev_linux_run(const struct netdev_class *);

int get_stats_via_netlink(const struct netdev *netdev_,
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
11 changes: 11 additions & 0 deletions vswitchd/vswitch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3854,6 +3854,17 @@ ovs-vsctl add-port br0 p0 -- set Interface p0 type=patch options:peer=p1 \
Whether userspace-tso is enabled or disabled.
</column>
</group>

<group title="afxdp">
<p>
AF_XDP specific interface status options.
</p>

<column name="status" key="xdp-mode">
XDP mode currently in use. See <ref column="options"
key="xdp-mode"/> for description of possible values.
</column>
</group>
</group>

<group title="Statistics">
Expand Down

0 comments on commit d614f28

Please sign in to comment.