Skip to content

Commit

Permalink
netdev-dummy: 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 tests have been updated accordingly.

Reported-at: https://bugzilla.redhat.com/1949855
Signed-off-by: Jakob Meng <code@jakobmeng.de>
Reviewed-by: Robin Jarry <rjarry@redhat.com>
Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
  • Loading branch information
JM1 authored and kevintraynor committed Nov 14, 2023
1 parent bf843fd commit 169c6b2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
19 changes: 15 additions & 4 deletions lib/netdev-dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,14 +795,25 @@ 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 */

if (netdev->ol_ip_csum) {
smap_add_format(args, "ol_ip_csum", "%s", "true");
}

if (netdev->ol_ip_csum_set_good) {
smap_add_format(args, "ol_ip_csum_set_good", "%s", "true");
}

/* '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
26 changes: 13 additions & 13 deletions tests/pmd.at
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ pmd thread numa_id <cleared> core_id <cleared>:
overhead: NOT AVAIL
])

AT_CHECK([ovs-appctl dpif/show | sed 's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
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-pmd: configured_rx_queues=1, configured_tx_queues=<cleared>, requested_rx_queues=1, requested_tx_queues=<cleared>)
p0 1/1: (dummy-pmd: n_rxq=1, n_txq=1, numa_id=0)
])

OVS_VSWITCHD_STOP
Expand All @@ -111,11 +111,11 @@ CHECK_PMD_THREADS_CREATED()

AT_CHECK([ovs-vsctl set interface p0 options:n_rxq=8])

AT_CHECK([ovs-appctl dpif/show | sed 's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
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-pmd: configured_rx_queues=8, configured_tx_queues=<cleared>, requested_rx_queues=8, requested_tx_queues=<cleared>)
p0 1/1: (dummy-pmd: n_rxq=8, n_txq=1, numa_id=0)
])

AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | sed SED_NUMA_CORE_PATTERN], [0], [dnl
Expand Down Expand Up @@ -144,11 +144,11 @@ OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy-pmd options:n
CHECK_CPU_DISCOVERED(2)
CHECK_PMD_THREADS_CREATED()

AT_CHECK([ovs-appctl dpif/show | sed 's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
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-pmd: configured_rx_queues=8, configured_tx_queues=<cleared>, requested_rx_queues=8, requested_tx_queues=<cleared>)
p0 1/1: (dummy-pmd: n_rxq=8, n_txq=1, numa_id=0)
])

AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | sed SED_NUMA_CORE_PATTERN], [0], [dnl
Expand Down Expand Up @@ -227,11 +227,11 @@ TMP=$(($(cat ovs-vswitchd.log | wc -l | tr -d [[:blank:]])+1))
CHECK_CPU_DISCOVERED(4)
CHECK_PMD_THREADS_CREATED()

AT_CHECK([ovs-appctl dpif/show | sed 's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
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-pmd: configured_rx_queues=8, configured_tx_queues=<cleared>, requested_rx_queues=8, requested_tx_queues=<cleared>)
p0 1/1: (dummy-pmd: n_rxq=8, n_txq=1, numa_id=1)
])

AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | sed SED_NUMA_CORE_PATTERN], [0], [dnl
Expand Down Expand Up @@ -436,11 +436,11 @@ AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:smc-enable=true])

sleep 1

AT_CHECK([ovs-appctl dpif/show | sed 's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
AT_CHECK([ovs-appctl dpif/show], [0], [dnl
dummy@ovs-dummy: hit:0 missed:0
br0:
br0 65534/100: (dummy-internal)
p0 7/1: (dummy-pmd: configured_rx_queues=4, configured_tx_queues=<cleared>, requested_rx_queues=4, requested_tx_queues=<cleared>)
p0 7/1: (dummy-pmd: n_rxq=4, n_txq=1, numa_id=0)
])

AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | sed SED_NUMA_CORE_PATTERN | sed '/cycles/d' | grep pmd -A 12], [0], [dnl
Expand Down Expand Up @@ -604,8 +604,8 @@ icmp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10
dnl Check resetting to default number of rx queues after removal from the db.
AT_CHECK([ovs-vsctl remove interface p1 options n_rxq])

AT_CHECK([ovs-appctl dpif/show | grep p1 | sed 's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
p1 1/1: (dummy-pmd: configured_rx_queues=1, configured_tx_queues=<cleared>, requested_rx_queues=1, requested_tx_queues=<cleared>)
AT_CHECK([ovs-appctl dpif/show | grep p1], [0], [dnl
p1 1/1: (dummy-pmd: n_rxq=1, n_txq=1, numa_id=0)
])

OVS_VSWITCHD_STOP
Expand Down Expand Up @@ -1152,7 +1152,7 @@ dummy@dp0:
lookups: hit:0 missed:0 lost:0
flows: 0
port 0: dp0 (dummy-internal)
port 1: p1 (dummy-pmd: configured_rx_queues=1, configured_tx_queues=1, requested_rx_queues=1, requested_tx_queues=1)
port 1: p1 (dummy-pmd: n_rxq=1, n_txq=1, numa_id=0)
port 2: p2 (dummy)
])

Expand Down

0 comments on commit 169c6b2

Please sign in to comment.