Skip to content

Commit

Permalink
netdev-dpdk: Add Flow Control support.
Browse files Browse the repository at this point in the history
Add support for flow-control(mac control frame) to DPDK enabled physical
port types. By default, the flow-control is OFF on both rx and tx side.
The flow control can be enabled/disabled either when adding a port to OVS
or at run time.

For eg:
To enable flow control support at tx side while adding a port, add the
'tx-flow-ctrl' option to the 'ovs-vsctl add-port' command-line as below.

 'ovs-vsctl add-port br0 dpdk0 -- \
  set Interface dpdk0 type=dpdk options:tx-flow-ctrl=true'

Similarly to enable rx flow control,
 'ovs-vsctl add-port br0 dpdk0 -- \
  set Interface dpdk0 type=dpdk options:rx-flow-ctrl=true'

And to enable the flow control auto-negotiation,
 'ovs-vsctl add-port br0 dpdk0 -- \
  set Interface dpdk0 type=dpdk options:flow-ctrl-autoneg=true'

To turn ON the tx flow control at run time(After the port is being added
to OVS), the command-line input will be,
 'ovs-vsctl set Interface dpdk0 options:tx-flow-ctrl=true'

The flow control parameters can be turned off by setting 'false' to the
respective parameter. To dsiable the flow control at tx side,
 'ovs-vsctl set Interface dpdk0 options:tx-flow-ctrl=false'

Signed-off-by: Sugesh Chandran <[email protected]>
Acked-by: Bhanuprakash Bodireddy <[email protected]>
Signed-off-by: Daniele Di Proietto <[email protected]>
  • Loading branch information
Sugesh Chandran authored and ddiproietto committed Jul 30, 2016
1 parent 5a27991 commit 9fd3937
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 2 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ Sten Spans [email protected]
Stephane A. Sezer [email protected]
Stephen Finucane [email protected]
Steve Ruan [email protected]
Sugesh Chandran [email protected]
SUGYO Kazushi [email protected]
Tadaaki Nagao [email protected]
Terry Wilson [email protected]
Expand Down
39 changes: 37 additions & 2 deletions INSTALL.DPDK-ADVANCED.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ OVS DPDK ADVANCED INSTALL GUIDE
6. [Vhost Walkthrough](#vhost)
7. [QOS](#qos)
8. [Rate Limiting](#rl)
9. [Vsperf](#vsperf)
9. [Flow Control](#fc)
10. [Vsperf](#vsperf)

## <a name="overview"></a> 1. Overview

Expand Down Expand Up @@ -827,7 +828,41 @@ To clear the ingress policer configuration from the port use the following:
For more details regarding ingress-policer see the vswitch.xml.
## <a name="vsperf"></a> 9. Vsperf
## <a name="fc"></a> 9. Flow control.
Flow control can be enabled only on DPDK physical ports.
To enable flow control support at tx side while adding a port, add the
'tx-flow-ctrl' option to the 'ovs-vsctl add-port' as in the eg: below.
```
ovs-vsctl add-port br0 dpdk0 -- \
set Interface dpdk0 type=dpdk options:tx-flow-ctrl=true
```
Similarly to enable rx flow control,
```
ovs-vsctl add-port br0 dpdk0 -- \
set Interface dpdk0 type=dpdk options:rx-flow-ctrl=true
```
And to enable the flow control auto-negotiation,
```
ovs-vsctl add-port br0 dpdk0 -- \
set Interface dpdk0 type=dpdk options:flow-ctrl-autoneg=true
```
To turn ON the tx flow control at run time(After the port is being added
to OVS), the command-line input will be,
`ovs-vsctl set Interface dpdk0 options:tx-flow-ctrl=true`
The flow control parameters can be turned off by setting 'false' to the
respective parameter. To disable the flow control at tx side,
`ovs-vsctl set Interface dpdk0 options:tx-flow-ctrl=false`
## <a name="vsperf"></a> 10. Vsperf
Vsperf project goal is to develop vSwitch test framework that can be used to
validate the suitability of different vSwitch implementations in a Telco deployment
Expand Down
36 changes: 36 additions & 0 deletions lib/netdev-dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ struct netdev_dpdk {
OVSRCU_TYPE(struct ingress_policer *) ingress_policer;
uint32_t policer_rate;
uint32_t policer_burst;

/* DPDK-ETH Flow control */
struct rte_eth_fc_conf fc_conf;
};

struct netdev_rxq_dpdk {
Expand Down Expand Up @@ -628,6 +631,13 @@ dpdk_eth_dev_queue_setup(struct netdev_dpdk *dev, int n_rxq, int n_txq)
return diag;
}

static void
dpdk_eth_flow_ctrl_setup(struct netdev_dpdk *dev) OVS_REQUIRES(dev->mutex)
{
if (rte_eth_dev_flow_ctrl_set(dev->port_id, &dev->fc_conf)) {
VLOG_WARN("Failed to enable flow control on device %d", dev->port_id);
}
}

static int
dpdk_eth_dev_init(struct netdev_dpdk *dev) OVS_REQUIRES(dpdk_mutex)
Expand Down Expand Up @@ -676,6 +686,14 @@ dpdk_eth_dev_init(struct netdev_dpdk *dev) OVS_REQUIRES(dpdk_mutex)
dev->buf_size = mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM;

dev->flags = NETDEV_UP | NETDEV_PROMISC;

/* Get the Flow control configuration for DPDK-ETH */
diag = rte_eth_dev_flow_ctrl_get(dev->port_id, &dev->fc_conf);
if (diag) {
VLOG_DBG("cannot get flow control parameters on port=%d, err=%d",
dev->port_id, diag);
}

return 0;
}

Expand Down Expand Up @@ -765,6 +783,8 @@ netdev_dpdk_init(struct netdev *netdev, unsigned int port_no,
dev->requested_n_rxq = netdev->n_rxq;
dev->requested_n_txq = netdev->n_txq;

/* Initialize the flow control to NULL */
memset(&dev->fc_conf, 0, sizeof dev->fc_conf);
if (type == DPDK_DEV_ETH) {
err = dpdk_eth_dev_init(dev);
if (err) {
Expand Down Expand Up @@ -983,6 +1003,22 @@ netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args)
dev->requested_n_rxq = new_n_rxq;
netdev_request_reconfigure(netdev);
}

/* Flow control configuration for DPDK Ethernet ports. */
if (dev->type == DPDK_DEV_ETH) {
bool rx_fc_en = false;
bool tx_fc_en = false;
enum rte_eth_fc_mode fc_mode_set[2][2] =
{{RTE_FC_NONE, RTE_FC_TX_PAUSE},
{RTE_FC_RX_PAUSE, RTE_FC_FULL}
};
rx_fc_en = smap_get_bool(args, "rx-flow-ctrl", false);
tx_fc_en = smap_get_bool(args, "tx-flow-ctrl", false);
dev->fc_conf.autoneg = smap_get_bool(args, "flow-ctrl-autoneg", false);
dev->fc_conf.mode = fc_mode_set[tx_fc_en][rx_fc_en];

dpdk_eth_flow_ctrl_setup(dev);
}
ovs_mutex_unlock(&dev->mutex);

return 0;
Expand Down
24 changes: 24 additions & 0 deletions vswitchd/vswitch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3146,6 +3146,30 @@
</column>
</group>

<group title="Flow control Configuration">
<p>
Ethernet flow control defined in IEEE 802.1Qbb provides link level flow
control using MAC pause frames. Implemented only for interfaces with
type <code>dpdk</code>.
</p>

<column name="options" key="rx-flow-ctrl" type='{"type": "boolean"}'>
Set to <code>true</code> to enable Rx flow control on physical ports.
By default, Rx flow control is disabled.
</column>

<column name="options" key="tx-flow-ctrl" type='{"type": "boolean"}'>
Set to <code>true</code> to enable Tx flow control on physical ports.
By default, Tx flow control is disabled.
</column>

<column name="options" key="flow-ctrl-autoneg"
type='{"type": "boolean"}'>
Set to <code>true</code> to enable flow control auto negotiation on
physical ports. By default, auto-neg is disabled.
</column>
</group>

<group title="Common Columns">
The overall purpose of these columns is described under <code>Common
Columns</code> at the beginning of this document.
Expand Down

0 comments on commit 9fd3937

Please sign in to comment.