On Tue, Oct 14, 2014 at 10:01 AM, David Verbeiren
<david.verbei...@intel.com> wrote:
> DPDK rings don't need one queue per PMD thread and don't support multiple
> queues (set_multiq function is undefined). To fix operation with DPDK rings,
> this patch ignores EOPNOTSUPP error on netdev_set_multiq() and provides, for
> DPDK rings, a netdev send() function that ignores the provided queue id
> (= PMD thread core id).
>
> Signed-off-by: David Verbeiren <david.verbei...@intel.com>
> Suggested-by: Maryam Tahhan <maryam.tah...@intel.com>

I added tx lock to protect dpdk rind txq and did couple of cleanups
and pushed patch to master.

Thanks,
Pravin.

> ---
> Patch -> V2:
> - Avoid testing type of netdev in send() by providing a different
> send() function for DPDK rings, as suggested by Pravin.
>
>  lib/dpif-netdev.c |  4 ++--
>  lib/netdev-dpdk.c | 29 +++++++++++++++++++++++------
>  2 files changed, 25 insertions(+), 8 deletions(-)
>
> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> index cea7c88..3ec115c 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> @@ -794,7 +794,7 @@ do_add_port(struct dp_netdev *dp, const char *devname, 
> const char *type,
>          /* There can only be ovs_numa_get_n_cores() pmd threads,
>           * so creates a txq for each. */
>          error = netdev_set_multiq(netdev, n_cores, dp->n_dpdk_rxqs);
> -        if (error) {
> +        if (error && (error != EOPNOTSUPP)) {
>              VLOG_ERR("%s, cannot set multiq", devname);
>              return errno;
>          }
> @@ -1958,7 +1958,7 @@ dpif_netdev_pmd_set(struct dpif *dpif, unsigned int 
> n_rxqs, const char *cmask)
>                  /* Sets the new rx queue config.  */
>                  err = netdev_set_multiq(port->netdev, ovs_numa_get_n_cores(),
>                                          n_rxqs);
> -                if (err) {
> +                if (err && (err != EOPNOTSUPP)) {
>                      VLOG_ERR("Failed to set dpdk interface %s rx_queue to:"
>                               " %u", netdev_get_name(port->netdev),
>                               n_rxqs);
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index 9c93768..4d8db84 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -845,8 +845,8 @@ dpdk_do_tx_copy(struct netdev *netdev, int qid, struct 
> dpif_packet ** pkts,
>      }
>  }
>
> -static int
> -netdev_dpdk_send(struct netdev *netdev, int qid, struct dpif_packet **pkts,
> +static inline int
> +netdev_dpdk_send__(struct netdev *netdev, int qid, struct dpif_packet **pkts,
>                   int cnt, bool may_steal)
>  {
>      struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
> @@ -900,6 +900,13 @@ netdev_dpdk_send(struct netdev *netdev, int qid, struct 
> dpif_packet **pkts,
>  }
>
>  static int
> +netdev_dpdk_eth_send(struct netdev *netdev, int qid, struct dpif_packet 
> **pkts,
> +                 int cnt, bool may_steal)
> +{
> +    netdev_dpdk_send__(netdev, qid, pkts, cnt, may_steal);
> +}
> +
> +static int
>  netdev_dpdk_set_etheraddr(struct netdev *netdev,
>                            const uint8_t mac[ETH_ADDR_LEN])
>  {
> @@ -1355,6 +1362,14 @@ dpdk_ring_open(const char dev_name[], unsigned int 
> *eth_port_id) OVS_REQUIRES(dp
>  }
>
>  static int
> +netdev_dpdk_ring_send(struct netdev *netdev, int qid, struct dpif_packet 
> **pkts,
> +                 int cnt, bool may_steal)
> +{
> +    netdev_dpdk_send__(netdev, 0 /* DPDK Rings have a single TX queue */,
> +                        pkts, cnt, may_steal);
> +}
> +
> +static int
>  netdev_dpdk_ring_construct(struct netdev *netdev)
>  {
>      unsigned int port_no = 0;
> @@ -1378,7 +1393,7 @@ unlock_dpdk:
>      return err;
>  }
>
> -#define NETDEV_DPDK_CLASS(NAME, INIT, CONSTRUCT, MULTIQ)      \
> +#define NETDEV_DPDK_CLASS(NAME, INIT, CONSTRUCT, MULTIQ, SEND)      \
>  {                                                             \
>      NAME,                                                     \
>      INIT,                       /* init */                    \
> @@ -1395,7 +1410,7 @@ unlock_dpdk:
>      netdev_dpdk_get_numa_id,    /* get_numa_id */             \
>      MULTIQ,                     /* set_multiq */              \
>                                                                \
> -    netdev_dpdk_send,           /* send */                    \
> +    SEND,                       /* send */                    \
>      NULL,                       /* send_wait */               \
>                                                                \
>      netdev_dpdk_set_etheraddr,                                \
> @@ -1481,14 +1496,16 @@ const struct netdev_class dpdk_class =
>          "dpdk",
>          dpdk_class_init,
>          netdev_dpdk_construct,
> -        netdev_dpdk_set_multiq);
> +        netdev_dpdk_set_multiq,
> +        netdev_dpdk_eth_send);
>
>  const struct netdev_class dpdk_ring_class =
>      NETDEV_DPDK_CLASS(
>          "dpdkr",
>          NULL,
>          netdev_dpdk_ring_construct,
> -        NULL);
> +        NULL,
> +        netdev_dpdk_ring_send);
>
>  void
>  netdev_dpdk_register(void)
> --
> 1.8.3.2
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to