[ovs-dev] [PATCH 1/3] netdev-dpdk: add hotplug support
Mauricio Vásquez
mauricio.vasquezbernal at studenti.polito.it
Fri Apr 1 14:58:53 UTC 2016
Hello Li,
On Fri, Apr 1, 2016 at 11:08 AM, Li Wei <lw at cn.fujitsu.com> wrote:
> Hello,
>
> On 03/28/2016 04:52 PM, Mauricio Vasquez B wrote:
> > In order to use dpdk ports in ovs they have to be bound to a DPDK
> > compatible driver before ovs is started.
> >
> > This patch adds the possibility to hotplug (or hot-unplug) a device
> > after ovs has been started. The implementation adds an appctl command:
> > netdev-dpdk/port-clt
> >
> > After the user attaches a new device, it has to be added to a bridge
> > using the to use the add-port command, similarly, before detaching a
> > device, it has to be removed using the del-port command.
>
> Do we need some additional check in dpdk_eth_dev_init(), because the
> port_id
> maybe discontinuous after a hot-unplug?
>
>
Yes, we need. Thanks for noticing it, it is also necessary to do some minor
modifications in the dpdk_ring_create() function due to the same reason.
I sent a v2: http://openvswitch.org/pipermail/dev/2016-April/069019.html
Mauricio Vasquez,
Thanks.
>
>
> >
> > Signed-off-by: Mauricio Vasquez B <
> mauricio.vasquezbernal at studenti.polito.it>
> > ---
> > lib/netdev-dpdk.c | 73
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 73 insertions(+)
> >
> > diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> > index 7c4cd07..05fa0df 100644
> > --- a/lib/netdev-dpdk.c
> > +++ b/lib/netdev-dpdk.c
> > @@ -1982,6 +1982,75 @@ netdev_dpdk_set_admin_state(struct unixctl_conn
> *conn, int argc,
> > unixctl_command_reply(conn, "OK");
> > }
> >
> > +static void
> > +netdev_dpdk_port_ctl(struct unixctl_conn *conn, int argc OVS_UNUSED,
> > + const char *argv[], void *aux OVS_UNUSED)
> > +{
> > + int ret;
> > + uint8_t port_id;
> > + unsigned int parsed_port;
> > + char devname[RTE_ETH_NAME_MAX_LEN];
> > + char response[512];
> > +
> > + ovs_mutex_lock(&dpdk_mutex);
> > +
> > + if (strcmp(argv[1], "attach") == 0) {
> > + ret = rte_eth_dev_attach(argv[2], &port_id);
> > + if (ret < 0) {
> > + snprintf(response, sizeof(response),
> > + "Error attaching device '%s'", argv[2]);
> > + unixctl_command_reply_error(conn, response);
> > + goto unlock;
> > + }
> > +
> > + snprintf(response, sizeof(response),
> > + "Device '%s' has been attached as 'dpdk%d'", argv[2],
> port_id);
> > + unixctl_command_reply(conn, response);
> > +
> > + } else if (strcmp(argv[1], "detach") == 0) {
> > + ret = dpdk_dev_parse_name(argv[2], "dpdk", &parsed_port);
> > + if (ret) {
> > + snprintf(response, sizeof(response),
> > + "'%s' is not a valid dpdk device", argv[2]);
> > + unixctl_command_reply_error(conn, response);
> > + goto unlock;
> > + }
> > +
> > + port_id = parsed_port;
> > +
> > + struct netdev * netdev = netdev_from_name(argv[2]);
> > + if (netdev) {
> > + netdev_close(netdev);
> > + snprintf(response, sizeof(response),
> > + "Port '%s' is being used. Remove it before
> detaching",
> > + argv[2]);
> > + unixctl_command_reply_error(conn, response);
> > + goto unlock;
> > + }
> > +
> > + rte_eth_dev_close(port_id);
> > +
> > + ret = rte_eth_dev_detach(port_id, devname);
> > + if (ret < 0) {
> > + snprintf(response, sizeof(response),
> > + "Port '%s' can not be detached", argv[2]);
> > + unixctl_command_reply_error(conn, response);
> > + goto unlock;
> > + }
> > +
> > + snprintf(response, sizeof(response),
> > + "Port '%s' has been detached", argv[2]);
> > + unixctl_command_reply(conn, response);
> > + } else {
> > + snprintf(response, sizeof(response),
> > + "'%s' is not a valid argument", argv[1]);
> > + unixctl_command_reply_error(conn, response);
> > + }
> > +
> > +unlock:
> > + ovs_mutex_unlock(&dpdk_mutex);
> > +}
> > +
> > /*
> > * Set virtqueue flags so that we do not receive interrupts.
> > */
> > @@ -2262,6 +2331,10 @@ dpdk_common_init(void)
> > "[netdev] up|down", 1, 2,
> > netdev_dpdk_set_admin_state, NULL);
> >
> > + unixctl_command_register("netdev-dpdk/port-ctl",
> > + "attach/detach device", 2, 2,
> > + netdev_dpdk_port_ctl, NULL);
> > +
> > ovs_thread_create("dpdk_watchdog", dpdk_watchdog, NULL);
> > }
> >
> >
>
>
>
More information about the dev
mailing list