2014-03-24 19:23:08 -07:00
|
|
|
/*
|
2017-04-03 13:27:47 +01:00
|
|
|
* Copyright (c) 2014, 2015, 2016, 2017 Nicira, Inc.
|
2014-03-24 19:23:08 -07:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at:
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2016-10-04 17:58:05 -07:00
|
|
|
#include "netdev-dpdk.h"
|
2014-03-24 19:23:08 -07:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
2017-08-01 16:14:10 -07:00
|
|
|
#include <linux/virtio_net.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <linux/if.h>
|
2016-10-04 17:58:05 -07:00
|
|
|
|
2017-12-08 10:53:46 +00:00
|
|
|
#include <rte_bus_pci.h>
|
2016-10-04 17:58:05 -07:00
|
|
|
#include <rte_config.h>
|
|
|
|
#include <rte_cycles.h>
|
|
|
|
#include <rte_errno.h>
|
|
|
|
#include <rte_eth_ring.h>
|
|
|
|
#include <rte_ethdev.h>
|
|
|
|
#include <rte_malloc.h>
|
|
|
|
#include <rte_mbuf.h>
|
|
|
|
#include <rte_meter.h>
|
2017-08-09 16:00:53 -04:00
|
|
|
#include <rte_pci.h>
|
2017-08-01 16:14:10 -07:00
|
|
|
#include <rte_vhost.h>
|
2017-11-14 10:59:44 +00:00
|
|
|
#include <rte_version.h>
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2015-06-04 06:51:40 -07:00
|
|
|
#include "dirs.h"
|
2015-02-25 12:01:53 -08:00
|
|
|
#include "dp-packet.h"
|
2016-10-04 17:58:05 -07:00
|
|
|
#include "dpdk.h"
|
2014-03-24 19:23:08 -07:00
|
|
|
#include "dpif-netdev.h"
|
2016-02-02 14:02:15 +03:00
|
|
|
#include "fatal-signal.h"
|
2014-03-24 19:23:08 -07:00
|
|
|
#include "netdev-provider.h"
|
|
|
|
#include "netdev-vport.h"
|
|
|
|
#include "odp-util.h"
|
2016-04-29 13:44:04 -04:00
|
|
|
#include "openvswitch/dynamic-string.h"
|
2016-04-14 15:20:21 -07:00
|
|
|
#include "openvswitch/list.h"
|
|
|
|
#include "openvswitch/ofp-print.h"
|
|
|
|
#include "openvswitch/vlog.h"
|
2014-09-04 13:09:22 -07:00
|
|
|
#include "ovs-numa.h"
|
2014-03-24 19:23:08 -07:00
|
|
|
#include "ovs-thread.h"
|
|
|
|
#include "ovs-rcu.h"
|
|
|
|
#include "packets.h"
|
2016-07-12 16:37:34 -05:00
|
|
|
#include "openvswitch/shash.h"
|
2016-03-02 20:35:54 +00:00
|
|
|
#include "smap.h"
|
2014-03-24 19:23:08 -07:00
|
|
|
#include "sset.h"
|
|
|
|
#include "unaligned.h"
|
|
|
|
#include "timeval.h"
|
|
|
|
#include "unixctl.h"
|
|
|
|
|
2017-08-01 16:14:10 -07:00
|
|
|
enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM};
|
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
VLOG_DEFINE_THIS_MODULE(netdev_dpdk);
|
2014-03-24 19:23:08 -07:00
|
|
|
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20);
|
|
|
|
|
|
|
|
#define DPDK_PORT_WATCHDOG_INTERVAL 5
|
|
|
|
|
|
|
|
#define OVS_CACHE_LINE_SIZE CACHE_LINE_SIZE
|
|
|
|
#define OVS_VPORT_DPDK "ovs_dpdk"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* need to reserve tons of extra space in the mbufs so we can align the
|
|
|
|
* DMA addresses to 4KB.
|
2015-09-04 13:35:57 +01:00
|
|
|
* The minimum mbuf size is limited to avoid scatter behaviour and drop in
|
|
|
|
* performance for standard Ethernet MTU.
|
2014-03-24 19:23:08 -07:00
|
|
|
*/
|
2016-09-29 11:27:03 +01:00
|
|
|
#define ETHER_HDR_MAX_LEN (ETHER_HDR_LEN + ETHER_CRC_LEN \
|
|
|
|
+ (2 * VLAN_HEADER_LEN))
|
2016-02-19 11:25:11 +00:00
|
|
|
#define MTU_TO_FRAME_LEN(mtu) ((mtu) + ETHER_HDR_LEN + ETHER_CRC_LEN)
|
|
|
|
#define MTU_TO_MAX_FRAME_LEN(mtu) ((mtu) + ETHER_HDR_MAX_LEN)
|
2016-09-29 11:27:03 +01:00
|
|
|
#define FRAME_LEN_TO_MTU(frame_len) ((frame_len) \
|
|
|
|
- ETHER_HDR_LEN - ETHER_CRC_LEN)
|
2017-06-12 14:38:18 +00:00
|
|
|
#define MBUF_SIZE(mtu) ROUND_UP((MTU_TO_MAX_FRAME_LEN(mtu) \
|
|
|
|
+ sizeof(struct dp_packet) \
|
|
|
|
+ RTE_PKTMBUF_HEADROOM), \
|
|
|
|
RTE_CACHE_LINE_SIZE)
|
2016-02-19 11:25:11 +00:00
|
|
|
#define NETDEV_DPDK_MBUF_ALIGN 1024
|
2016-08-09 17:01:20 +01:00
|
|
|
#define NETDEV_DPDK_MAX_PKT_LEN 9728
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2017-11-10 18:16:12 +03:00
|
|
|
/* Min number of packets in the mempool. OVS tries to allocate a mempool with
|
|
|
|
* roughly estimated number of mbufs: if this fails (because the system doesn't
|
|
|
|
* have enough hugepages) we keep halving the number until the allocation
|
|
|
|
* succeeds or we reach MIN_NB_MBUF */
|
2015-03-12 18:04:32 +00:00
|
|
|
#define MIN_NB_MBUF (4096 * 4)
|
|
|
|
#define MP_CACHE_SZ RTE_MEMPOOL_CACHE_MAX_SIZE
|
|
|
|
|
2016-05-05 09:46:01 +01:00
|
|
|
/*
|
|
|
|
* DPDK XSTATS Counter names definition
|
|
|
|
*/
|
|
|
|
#define XSTAT_RX_64_PACKETS "rx_size_64_packets"
|
|
|
|
#define XSTAT_RX_65_TO_127_PACKETS "rx_size_65_to_127_packets"
|
|
|
|
#define XSTAT_RX_128_TO_255_PACKETS "rx_size_128_to_255_packets"
|
|
|
|
#define XSTAT_RX_256_TO_511_PACKETS "rx_size_256_to_511_packets"
|
|
|
|
#define XSTAT_RX_512_TO_1023_PACKETS "rx_size_512_to_1023_packets"
|
|
|
|
#define XSTAT_RX_1024_TO_1522_PACKETS "rx_size_1024_to_1522_packets"
|
|
|
|
#define XSTAT_RX_1523_TO_MAX_PACKETS "rx_size_1523_to_max_packets"
|
|
|
|
|
|
|
|
#define XSTAT_TX_64_PACKETS "tx_size_64_packets"
|
|
|
|
#define XSTAT_TX_65_TO_127_PACKETS "tx_size_65_to_127_packets"
|
|
|
|
#define XSTAT_TX_128_TO_255_PACKETS "tx_size_128_to_255_packets"
|
|
|
|
#define XSTAT_TX_256_TO_511_PACKETS "tx_size_256_to_511_packets"
|
|
|
|
#define XSTAT_TX_512_TO_1023_PACKETS "tx_size_512_to_1023_packets"
|
|
|
|
#define XSTAT_TX_1024_TO_1522_PACKETS "tx_size_1024_to_1522_packets"
|
|
|
|
#define XSTAT_TX_1523_TO_MAX_PACKETS "tx_size_1523_to_max_packets"
|
|
|
|
|
2017-04-28 10:51:30 +01:00
|
|
|
#define XSTAT_RX_MULTICAST_PACKETS "rx_multicast_packets"
|
2016-05-05 09:46:01 +01:00
|
|
|
#define XSTAT_TX_MULTICAST_PACKETS "tx_multicast_packets"
|
|
|
|
#define XSTAT_RX_BROADCAST_PACKETS "rx_broadcast_packets"
|
|
|
|
#define XSTAT_TX_BROADCAST_PACKETS "tx_broadcast_packets"
|
|
|
|
#define XSTAT_RX_UNDERSIZED_ERRORS "rx_undersized_errors"
|
|
|
|
#define XSTAT_RX_OVERSIZE_ERRORS "rx_oversize_errors"
|
|
|
|
#define XSTAT_RX_FRAGMENTED_ERRORS "rx_fragmented_errors"
|
|
|
|
#define XSTAT_RX_JABBER_ERRORS "rx_jabber_errors"
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
#define SOCKET0 0
|
|
|
|
|
2016-09-30 14:50:53 +01:00
|
|
|
/* Default size of Physical NIC RXQ */
|
|
|
|
#define NIC_PORT_DEFAULT_RXQ_SIZE 2048
|
|
|
|
/* Default size of Physical NIC TXQ */
|
|
|
|
#define NIC_PORT_DEFAULT_TXQ_SIZE 2048
|
|
|
|
/* Maximum size of Physical NIC Queues */
|
|
|
|
#define NIC_PORT_MAX_Q_SIZE 4096
|
2014-06-19 22:58:26 +00:00
|
|
|
|
2016-02-24 17:14:43 +03:00
|
|
|
#define OVS_VHOST_MAX_QUEUE_NUM 1024 /* Maximum number of vHost TX queues. */
|
2016-03-29 09:20:41 +03:00
|
|
|
#define OVS_VHOST_QUEUE_MAP_UNKNOWN (-1) /* Mapping not initialized. */
|
|
|
|
#define OVS_VHOST_QUEUE_DISABLED (-2) /* Queue was disabled by guest and not
|
|
|
|
* yet mapped to another queue. */
|
2016-02-24 17:14:43 +03:00
|
|
|
|
2017-05-19 16:37:32 +03:00
|
|
|
#define DPDK_ETH_PORT_ID_INVALID RTE_MAX_ETHPORTS
|
|
|
|
|
2017-12-08 10:53:46 +00:00
|
|
|
/* DPDK library uses uint16_t for port_id. */
|
|
|
|
typedef uint16_t dpdk_port_t;
|
2018-02-21 17:39:35 +03:00
|
|
|
#define DPDK_PORT_ID_FMT "%"PRIu16
|
2017-05-19 16:37:32 +03:00
|
|
|
|
2016-06-10 17:49:38 +01:00
|
|
|
#define VHOST_ENQ_RETRY_NUM 8
|
2016-08-03 13:29:24 +01:00
|
|
|
#define IF_NAME_SZ (PATH_MAX > IFNAMSIZ ? PATH_MAX : IFNAMSIZ)
|
2015-05-11 21:58:14 -07:00
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
static const struct rte_eth_conf port_conf = {
|
2014-06-24 16:05:01 -07:00
|
|
|
.rxmode = {
|
|
|
|
.mq_mode = ETH_MQ_RX_RSS,
|
|
|
|
.split_hdr_size = 0,
|
|
|
|
.header_split = 0, /* Header Split disabled */
|
|
|
|
.hw_ip_checksum = 0, /* IP checksum offload disabled */
|
|
|
|
.hw_vlan_filter = 0, /* VLAN filtering disabled */
|
|
|
|
.jumbo_frame = 0, /* Jumbo Frame Support disabled */
|
|
|
|
.hw_strip_crc = 0,
|
|
|
|
},
|
|
|
|
.rx_adv_conf = {
|
|
|
|
.rss_conf = {
|
|
|
|
.rss_key = NULL,
|
2015-04-20 12:37:14 -07:00
|
|
|
.rss_hf = ETH_RSS_IP | ETH_RSS_UDP | ETH_RSS_TCP,
|
2014-03-24 19:23:08 -07:00
|
|
|
},
|
2014-06-24 16:05:01 -07:00
|
|
|
},
|
|
|
|
.txmode = {
|
|
|
|
.mq_mode = ETH_MQ_TX_NONE,
|
|
|
|
},
|
2014-03-24 19:23:08 -07:00
|
|
|
};
|
|
|
|
|
2017-08-01 16:14:10 -07:00
|
|
|
/*
|
|
|
|
* These callbacks allow virtio-net devices to be added to vhost ports when
|
|
|
|
* configuration has been fully completed.
|
|
|
|
*/
|
|
|
|
static int new_device(int vid);
|
|
|
|
static void destroy_device(int vid);
|
|
|
|
static int vring_state_changed(int vid, uint16_t queue_id, int enable);
|
|
|
|
static const struct vhost_device_ops virtio_net_device_ops =
|
|
|
|
{
|
|
|
|
.new_device = new_device,
|
|
|
|
.destroy_device = destroy_device,
|
|
|
|
.vring_state_changed = vring_state_changed,
|
|
|
|
.features_changed = NULL
|
|
|
|
};
|
|
|
|
|
2014-07-30 08:51:34 -07:00
|
|
|
enum { DPDK_RING_SIZE = 256 };
|
|
|
|
BUILD_ASSERT_DECL(IS_POW2(DPDK_RING_SIZE));
|
2014-03-24 19:23:08 -07:00
|
|
|
enum { DRAIN_TSC = 200000ULL };
|
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
enum dpdk_dev_type {
|
|
|
|
DPDK_DEV_ETH = 0,
|
2015-06-04 06:51:40 -07:00
|
|
|
DPDK_DEV_VHOST = 1,
|
2015-03-05 13:42:04 -08:00
|
|
|
};
|
|
|
|
|
2016-03-02 20:35:54 +00:00
|
|
|
/* Quality of Service */
|
|
|
|
|
|
|
|
/* An instance of a QoS configuration. Always associated with a particular
|
|
|
|
* network device.
|
|
|
|
*
|
|
|
|
* Each QoS implementation subclasses this with whatever additional data it
|
|
|
|
* needs.
|
|
|
|
*/
|
|
|
|
struct qos_conf {
|
|
|
|
const struct dpdk_qos_ops *ops;
|
2016-10-04 17:58:05 -07:00
|
|
|
rte_spinlock_t lock;
|
2016-03-02 20:35:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* A particular implementation of dpdk QoS operations.
|
|
|
|
*
|
|
|
|
* The functions below return 0 if successful or a positive errno value on
|
|
|
|
* failure, except where otherwise noted. All of them must be provided, except
|
|
|
|
* where otherwise noted.
|
|
|
|
*/
|
|
|
|
struct dpdk_qos_ops {
|
|
|
|
|
|
|
|
/* Name of the QoS type */
|
|
|
|
const char *qos_name;
|
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
/* Called to construct a qos_conf object. The implementation should make
|
|
|
|
* the appropriate calls to configure QoS according to 'details'.
|
2016-03-02 20:35:54 +00:00
|
|
|
*
|
|
|
|
* The contents of 'details' should be documented as valid for 'ovs_name'
|
|
|
|
* in the "other_config" column in the "QoS" table in vswitchd/vswitch.xml
|
|
|
|
* (which is built as ovs-vswitchd.conf.db(8)).
|
|
|
|
*
|
2016-10-04 17:58:05 -07:00
|
|
|
* This function must return 0 if and only if it sets '*conf' to an
|
|
|
|
* initialized 'struct qos_conf'.
|
2016-03-02 20:35:54 +00:00
|
|
|
*
|
|
|
|
* For all QoS implementations it should always be non-null.
|
|
|
|
*/
|
2016-10-04 17:58:05 -07:00
|
|
|
int (*qos_construct)(const struct smap *details, struct qos_conf **conf);
|
2016-03-02 20:35:54 +00:00
|
|
|
|
|
|
|
/* Destroys the data structures allocated by the implementation as part of
|
2016-10-04 17:58:05 -07:00
|
|
|
* 'qos_conf'.
|
2016-03-02 20:35:54 +00:00
|
|
|
*
|
|
|
|
* For all QoS implementations it should always be non-null.
|
|
|
|
*/
|
2016-10-04 17:58:05 -07:00
|
|
|
void (*qos_destruct)(struct qos_conf *conf);
|
2016-03-02 20:35:54 +00:00
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
/* Retrieves details of 'conf' configuration into 'details'.
|
2016-03-02 20:35:54 +00:00
|
|
|
*
|
|
|
|
* The contents of 'details' should be documented as valid for 'ovs_name'
|
|
|
|
* in the "other_config" column in the "QoS" table in vswitchd/vswitch.xml
|
|
|
|
* (which is built as ovs-vswitchd.conf.db(8)).
|
|
|
|
*/
|
2016-10-04 17:58:05 -07:00
|
|
|
int (*qos_get)(const struct qos_conf *conf, struct smap *details);
|
2016-03-02 20:35:54 +00:00
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
/* Returns true if 'conf' is already configured according to 'details'.
|
2016-03-02 20:35:54 +00:00
|
|
|
*
|
|
|
|
* The contents of 'details' should be documented as valid for 'ovs_name'
|
|
|
|
* in the "other_config" column in the "QoS" table in vswitchd/vswitch.xml
|
|
|
|
* (which is built as ovs-vswitchd.conf.db(8)).
|
|
|
|
*
|
2016-10-04 17:58:05 -07:00
|
|
|
* For all QoS implementations it should always be non-null.
|
2016-03-02 20:35:54 +00:00
|
|
|
*/
|
2016-10-04 17:58:05 -07:00
|
|
|
bool (*qos_is_equal)(const struct qos_conf *conf,
|
|
|
|
const struct smap *details);
|
2016-03-02 20:35:54 +00:00
|
|
|
|
|
|
|
/* Modify an array of rte_mbufs. The modification is specific to
|
|
|
|
* each qos implementation.
|
|
|
|
*
|
|
|
|
* The function should take and array of mbufs and an int representing
|
|
|
|
* the current number of mbufs present in the array.
|
|
|
|
*
|
|
|
|
* After the function has performed a qos modification to the array of
|
|
|
|
* mbufs it returns an int representing the number of mbufs now present in
|
|
|
|
* the array. This value is can then be passed to the port send function
|
|
|
|
* along with the modified array for transmission.
|
|
|
|
*
|
|
|
|
* For all QoS implementations it should always be non-null.
|
|
|
|
*/
|
2016-10-04 17:58:05 -07:00
|
|
|
int (*qos_run)(struct qos_conf *qos_conf, struct rte_mbuf **pkts,
|
2018-05-16 19:24:46 -07:00
|
|
|
int pkt_cnt, bool should_steal);
|
2016-03-02 20:35:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* dpdk_qos_ops for each type of user space QoS implementation */
|
|
|
|
static const struct dpdk_qos_ops egress_policer_ops;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Array of dpdk_qos_ops, contains pointer to all supported QoS
|
|
|
|
* operations.
|
|
|
|
*/
|
|
|
|
static const struct dpdk_qos_ops *const qos_confs[] = {
|
|
|
|
&egress_policer_ops,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2016-09-23 16:17:58 +03:00
|
|
|
static struct ovs_mutex dpdk_mutex = OVS_MUTEX_INITIALIZER;
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
/* Contains all 'struct dpdk_dev's. */
|
2014-12-15 14:10:38 +01:00
|
|
|
static struct ovs_list dpdk_list OVS_GUARDED_BY(dpdk_mutex)
|
2014-12-15 14:10:38 +01:00
|
|
|
= OVS_LIST_INITIALIZER(&dpdk_list);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2016-09-23 16:17:58 +03:00
|
|
|
static struct ovs_mutex dpdk_mp_mutex OVS_ACQ_AFTER(dpdk_mutex)
|
|
|
|
= OVS_MUTEX_INITIALIZER;
|
|
|
|
|
2018-04-13 18:40:13 +01:00
|
|
|
/* Contains all 'struct dpdk_mp's. */
|
|
|
|
static struct ovs_list dpdk_mp_free_list OVS_GUARDED_BY(dpdk_mp_mutex)
|
|
|
|
= OVS_LIST_INITIALIZER(&dpdk_mp_free_list);
|
|
|
|
|
|
|
|
/* Wrapper for a mempool released but not yet freed. */
|
|
|
|
struct dpdk_mp {
|
|
|
|
struct rte_mempool *mp;
|
|
|
|
struct ovs_list list_node OVS_GUARDED_BY(dpdk_mp_mutex);
|
|
|
|
};
|
|
|
|
|
2014-06-17 10:52:20 -07:00
|
|
|
/* There should be one 'struct dpdk_tx_queue' created for
|
|
|
|
* each cpu core. */
|
2014-03-24 19:23:08 -07:00
|
|
|
struct dpdk_tx_queue {
|
2015-05-22 17:14:22 +01:00
|
|
|
rte_spinlock_t tx_lock; /* Protects the members and the NIC queue
|
|
|
|
* from concurrent access. It is used only
|
|
|
|
* if the queue is shared among different
|
2016-07-27 17:44:41 +03:00
|
|
|
* pmd threads (see 'concurrent_txq'). */
|
2016-02-24 17:14:43 +03:00
|
|
|
int map; /* Mapping of configured vhost-user queues
|
|
|
|
* to enabled by guest. */
|
2014-03-24 19:23:08 -07:00
|
|
|
};
|
|
|
|
|
2014-07-11 13:37:11 +01:00
|
|
|
/* dpdk has no way to remove dpdk ring ethernet devices
|
|
|
|
so we have to keep them around once they've been created
|
|
|
|
*/
|
|
|
|
|
2014-12-15 14:10:38 +01:00
|
|
|
static struct ovs_list dpdk_ring_list OVS_GUARDED_BY(dpdk_mutex)
|
2014-12-15 14:10:38 +01:00
|
|
|
= OVS_LIST_INITIALIZER(&dpdk_ring_list);
|
2014-07-11 13:37:11 +01:00
|
|
|
|
|
|
|
struct dpdk_ring {
|
|
|
|
/* For the client rings */
|
|
|
|
struct rte_ring *cring_tx;
|
|
|
|
struct rte_ring *cring_rx;
|
2016-02-23 23:06:37 +01:00
|
|
|
unsigned int user_port_id; /* User given port no, parsed from port name */
|
2017-05-19 16:37:32 +03:00
|
|
|
dpdk_port_t eth_port_id; /* ethernet device port id */
|
2014-12-15 14:10:38 +01:00
|
|
|
struct ovs_list list_node OVS_GUARDED_BY(dpdk_mutex);
|
2014-07-11 13:37:11 +01:00
|
|
|
};
|
|
|
|
|
2016-05-24 17:36:51 +01:00
|
|
|
struct ingress_policer {
|
|
|
|
struct rte_meter_srtcm_params app_srtcm_params;
|
|
|
|
struct rte_meter_srtcm in_policer;
|
|
|
|
rte_spinlock_t policer_lock;
|
|
|
|
};
|
|
|
|
|
netdev-dpdk: Enable Rx checksum offloading feature on DPDK physical ports.
Add Rx checksum offloading feature support on DPDK physical ports. By default,
the Rx checksum offloading is enabled if NIC supports. However,
the checksum offloading can be turned OFF either while adding a new DPDK
physical port to OVS or at runtime.
The rx checksum offloading can be turned off by setting the parameter to
'false'. For eg: To disable the rx checksum offloading when adding a port,
'ovs-vsctl add-port br0 dpdk0 -- \
set Interface dpdk0 type=dpdk options:rx-checksum-offload=false'
OR (to disable at run time after port is being added to OVS)
'ovs-vsctl set Interface dpdk0 options:rx-checksum-offload=false'
Similarly to turn ON rx checksum offloading at run time,
'ovs-vsctl set Interface dpdk0 options:rx-checksum-offload=true'
The Tx checksum offloading support is not implemented due to the following
reasons.
1) Checksum offloading and vectorization are mutually exclusive in DPDK poll
mode driver. Vector packet processing is turned OFF when checksum offloading
is enabled which causes significant performance drop at Tx side.
2) Normally, OVS generates checksum for tunnel packets in software at the
'tunnel push' operation, where the tunnel headers are created. However
enabling Tx checksum offloading involves,
*) Mark every packets for tx checksum offloading at 'tunnel_push' and
recirculate.
*) At the time of xmit, validate the same flag and instruct the NIC to do the
checksum calculation. In case NIC doesnt support Tx checksum offloading,
the checksum calculation has to be done in software before sending out the
packets.
No significant performance improvement noticed with Tx checksum offloading
due to the e overhead of additional validations + non vector packet processing.
In some test scenarios, it introduces performance drop too.
Rx checksum offloading still offers 8-9% of improvement on VxLAN tunneling
decapsulation even though the SSE vector Rx function is disabled in DPDK poll
mode driver.
Signed-off-by: Sugesh Chandran <sugesh.chandran@intel.com>
Acked-by: Jesse Gross <jesse@kernel.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
2017-01-02 14:27:48 -08:00
|
|
|
enum dpdk_hw_ol_features {
|
|
|
|
NETDEV_RX_CHECKSUM_OFFLOAD = 1 << 0,
|
|
|
|
};
|
|
|
|
|
2017-11-23 16:48:26 +03:00
|
|
|
/*
|
|
|
|
* In order to avoid confusion in variables names, following naming convention
|
|
|
|
* should be used, if possible:
|
|
|
|
*
|
|
|
|
* 'struct netdev' : 'netdev'
|
|
|
|
* 'struct netdev_dpdk' : 'dev'
|
|
|
|
* 'struct netdev_rxq' : 'rxq'
|
|
|
|
* 'struct netdev_rxq_dpdk' : 'rx'
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* struct netdev *netdev = netdev_from_name(name);
|
|
|
|
* struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
|
|
|
*
|
|
|
|
* Also, 'netdev' should be used instead of 'dev->up', where 'netdev' was
|
|
|
|
* already defined.
|
|
|
|
*/
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
struct netdev_dpdk {
|
2017-10-01 08:57:37 +01:00
|
|
|
PADDED_MEMBERS_CACHELINE_MARKER(CACHE_LINE_SIZE, cacheline0,
|
|
|
|
dpdk_port_t port_id;
|
|
|
|
|
|
|
|
/* If true, device was attached by rte_eth_dev_attach(). */
|
|
|
|
bool attached;
|
|
|
|
struct eth_addr hwaddr;
|
|
|
|
int mtu;
|
|
|
|
int socket_id;
|
|
|
|
int buf_size;
|
|
|
|
int max_packet_len;
|
|
|
|
enum dpdk_dev_type type;
|
|
|
|
enum netdev_flags flags;
|
2018-04-25 17:48:23 +02:00
|
|
|
int link_reset_cnt;
|
2017-10-01 08:57:37 +01:00
|
|
|
char *devargs; /* Device arguments for dpdk ports */
|
|
|
|
struct dpdk_tx_queue *tx_q;
|
|
|
|
struct rte_eth_link link;
|
|
|
|
);
|
|
|
|
|
|
|
|
PADDED_MEMBERS_CACHELINE_MARKER(CACHE_LINE_SIZE, cacheline1,
|
|
|
|
struct ovs_mutex mutex OVS_ACQ_AFTER(dpdk_mutex);
|
2017-11-10 18:16:11 +03:00
|
|
|
struct rte_mempool *mp;
|
2017-10-01 08:57:37 +01:00
|
|
|
|
|
|
|
/* virtio identifier for vhost devices */
|
|
|
|
ovsrcu_index vid;
|
|
|
|
|
|
|
|
/* True if vHost device is 'up' and has been reconfigured at least once */
|
|
|
|
bool vhost_reconfigured;
|
|
|
|
/* 3 pad bytes here. */
|
|
|
|
);
|
|
|
|
|
|
|
|
PADDED_MEMBERS(CACHE_LINE_SIZE,
|
|
|
|
/* Identifier used to distinguish vhost devices from each other. */
|
|
|
|
char vhost_id[PATH_MAX];
|
|
|
|
);
|
|
|
|
|
|
|
|
PADDED_MEMBERS(CACHE_LINE_SIZE,
|
|
|
|
struct netdev up;
|
|
|
|
/* In dpdk_list. */
|
|
|
|
struct ovs_list list_node OVS_GUARDED_BY(dpdk_mutex);
|
|
|
|
|
|
|
|
/* QoS configuration and lock for the device */
|
|
|
|
OVSRCU_TYPE(struct qos_conf *) qos_conf;
|
|
|
|
|
|
|
|
/* Ingress Policer */
|
|
|
|
OVSRCU_TYPE(struct ingress_policer *) ingress_policer;
|
|
|
|
uint32_t policer_rate;
|
|
|
|
uint32_t policer_burst;
|
|
|
|
);
|
|
|
|
|
|
|
|
PADDED_MEMBERS(CACHE_LINE_SIZE,
|
|
|
|
struct netdev_stats stats;
|
|
|
|
/* Protects stats */
|
|
|
|
rte_spinlock_t stats_lock;
|
|
|
|
/* 44 pad bytes here. */
|
|
|
|
);
|
|
|
|
|
|
|
|
PADDED_MEMBERS(CACHE_LINE_SIZE,
|
|
|
|
/* The following properties cannot be changed when a device is running,
|
|
|
|
* so we remember the request and update them next time
|
|
|
|
* netdev_dpdk*_reconfigure() is called */
|
|
|
|
int requested_mtu;
|
|
|
|
int requested_n_txq;
|
|
|
|
int requested_n_rxq;
|
|
|
|
int requested_rxq_size;
|
|
|
|
int requested_txq_size;
|
|
|
|
|
|
|
|
/* Number of rx/tx descriptors for physical devices */
|
|
|
|
int rxq_size;
|
|
|
|
int txq_size;
|
|
|
|
|
|
|
|
/* Socket ID detected when vHost device is brought up */
|
|
|
|
int requested_socket_id;
|
|
|
|
|
|
|
|
/* Denotes whether vHost port is client/server mode */
|
|
|
|
uint64_t vhost_driver_flags;
|
|
|
|
|
|
|
|
/* DPDK-ETH Flow control */
|
|
|
|
struct rte_eth_fc_conf fc_conf;
|
|
|
|
|
|
|
|
/* DPDK-ETH hardware offload features,
|
|
|
|
* from the enum set 'dpdk_hw_ol_features' */
|
|
|
|
uint32_t hw_ol_features;
|
2018-04-23 11:42:41 +00:00
|
|
|
|
|
|
|
/* Properties for link state change detection mode.
|
|
|
|
* If lsc_interrupt_mode is set to false, poll mode is used,
|
|
|
|
* otherwise interrupt mode is used. */
|
|
|
|
bool requested_lsc_interrupt_mode;
|
|
|
|
bool lsc_interrupt_mode;
|
2017-10-01 08:57:37 +01:00
|
|
|
);
|
2018-01-09 07:55:37 +00:00
|
|
|
|
|
|
|
PADDED_MEMBERS(CACHE_LINE_SIZE,
|
|
|
|
/* Names of all XSTATS counters */
|
|
|
|
struct rte_eth_xstat_name *rte_xstats_names;
|
|
|
|
int rte_xstats_names_size;
|
|
|
|
int rte_xstats_ids_size;
|
|
|
|
uint64_t *rte_xstats_ids;
|
|
|
|
);
|
2014-03-24 19:23:08 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct netdev_rxq_dpdk {
|
|
|
|
struct netdev_rxq up;
|
2017-05-19 16:37:32 +03:00
|
|
|
dpdk_port_t port_id;
|
2014-03-24 19:23:08 -07:00
|
|
|
};
|
|
|
|
|
2017-08-01 16:14:10 -07:00
|
|
|
static void netdev_dpdk_destruct(struct netdev *netdev);
|
|
|
|
static void netdev_dpdk_vhost_destruct(struct netdev *netdev);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2018-01-23 10:51:31 +03:00
|
|
|
static void netdev_dpdk_clear_xstats(struct netdev_dpdk *dev);
|
|
|
|
|
2016-08-03 13:29:24 +01:00
|
|
|
int netdev_dpdk_get_vid(const struct netdev_dpdk *dev);
|
2015-03-05 13:42:04 -08:00
|
|
|
|
2016-05-24 17:36:51 +01:00
|
|
|
struct ingress_policer *
|
|
|
|
netdev_dpdk_get_ingress_policer(const struct netdev_dpdk *dev);
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
static bool
|
|
|
|
is_dpdk_class(const struct netdev_class *class)
|
|
|
|
{
|
2017-08-01 16:14:10 -07:00
|
|
|
return class->destruct == netdev_dpdk_destruct
|
|
|
|
|| class->destruct == netdev_dpdk_vhost_destruct;
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
|
2016-02-19 11:25:11 +00:00
|
|
|
/* DPDK NIC drivers allocate RX buffers at a particular granularity, typically
|
|
|
|
* aligned at 1k or less. If a declared mbuf size is not a multiple of this
|
|
|
|
* value, insufficient buffers are allocated to accomodate the packet in its
|
|
|
|
* entirety. Furthermore, certain drivers need to ensure that there is also
|
|
|
|
* sufficient space in the Rx buffer to accommodate two VLAN tags (for QinQ
|
|
|
|
* frames). If the RX buffer is too small, then the driver enables scatter RX
|
2016-09-29 11:27:03 +01:00
|
|
|
* behaviour, which reduces performance. To prevent this, use a buffer size
|
|
|
|
* that is closest to 'mtu', but which satisfies the aforementioned criteria.
|
2016-02-19 11:25:11 +00:00
|
|
|
*/
|
|
|
|
static uint32_t
|
|
|
|
dpdk_buf_size(int mtu)
|
|
|
|
{
|
|
|
|
return ROUND_UP((MTU_TO_MAX_FRAME_LEN(mtu) + RTE_PKTMBUF_HEADROOM),
|
|
|
|
NETDEV_DPDK_MBUF_ALIGN);
|
|
|
|
}
|
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
/* Allocates an area of 'sz' bytes from DPDK. The memory is zero'ed.
|
|
|
|
*
|
|
|
|
* Unlike xmalloc(), this function can return NULL on failure. */
|
2014-03-24 19:23:08 -07:00
|
|
|
static void *
|
|
|
|
dpdk_rte_mzalloc(size_t sz)
|
|
|
|
{
|
2016-10-04 17:58:05 -07:00
|
|
|
return rte_zmalloc(OVS_VPORT_DPDK, sz, OVS_CACHE_LINE_SIZE);
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-02-25 12:01:53 -08:00
|
|
|
free_dpdk_buf(struct dp_packet *p)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
netdev-dpdk: Fix race condition with DPDK mempools in non pmd threads
DPDK mempools rely on rte_lcore_id() to implement a thread-local cache.
Our non pmd threads had rte_lcore_id() == 0. This allowed concurrent access to
the "thread-local" cache, causing crashes.
This commit resolves the issue with the following changes:
- Every non pmd thread has the same lcore_id (0, for management reasons), which
is not shared with any pmd thread (lcore_id for pmd threads now start from 1)
- DPDK mbufs must be allocated/freed in pmd threads. When there is the need to
use mempools in non pmd threads, like in dpdk_do_tx_copy(), a mutex must be
held.
- The previous change does not allow us anymore to pass DPDK mbufs to handler
threads: therefore this commit partially revert 143859ec63d45e. Now packets
are copied for upcall processing. We can remove the extra memcpy by
processing upcalls in the pmd thread itself.
With the introduction of the extra locking, the packet throughput will be lower
in the following cases:
- When using internal (tap) devices with DPDK devices on the same datapath.
Anyway, to support internal devices efficiently, we needed DPDK KNI devices,
which will be proper pmd devices and will not need this locking.
- When packets are processed in the slow path by non pmd threads. This overhead
can be avoided by handling the upcalls directly in pmd threads (a change that
has already been proposed by Ryan Wilson)
Also, the following two fixes have been introduced:
- In dpdk_free_buf() use rte_pktmbuf_free_seg() instead of rte_mempool_put().
This allows OVS to run properly with CONFIG_RTE_LIBRTE_MBUF_DEBUG DPDK option
- Do not bulk free mbufs in a transmission queue. They may belong to different
mempools
Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
2014-07-17 14:29:36 -07:00
|
|
|
struct rte_mbuf *pkt = (struct rte_mbuf *) p;
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2016-03-08 09:50:48 +08:00
|
|
|
rte_pktmbuf_free(pkt);
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
|
2014-03-31 13:17:24 -07:00
|
|
|
static void
|
2017-04-13 11:01:53 +05:30
|
|
|
ovs_rte_pktmbuf_init(struct rte_mempool *mp OVS_UNUSED,
|
2014-03-31 13:17:24 -07:00
|
|
|
void *opaque_arg OVS_UNUSED,
|
2016-09-29 11:27:02 +01:00
|
|
|
void *_p,
|
2014-03-31 13:17:24 -07:00
|
|
|
unsigned i OVS_UNUSED)
|
|
|
|
{
|
2016-09-29 11:27:02 +01:00
|
|
|
struct rte_mbuf *pkt = _p;
|
2014-03-31 13:17:24 -07:00
|
|
|
|
2016-09-29 11:27:02 +01:00
|
|
|
dp_packet_init_dpdk((struct dp_packet *) pkt, pkt->buf_len);
|
2014-03-31 13:17:24 -07:00
|
|
|
}
|
|
|
|
|
2018-04-13 18:40:13 +01:00
|
|
|
static int
|
|
|
|
dpdk_mp_full(const struct rte_mempool *mp) OVS_REQUIRES(dpdk_mp_mutex)
|
|
|
|
{
|
|
|
|
unsigned ring_count;
|
|
|
|
/* This logic is needed because rte_mempool_full() is not guaranteed to
|
|
|
|
* be atomic and mbufs could be moved from mempool cache --> mempool ring
|
|
|
|
* during the call. However, as no mbufs will be taken from the mempool
|
|
|
|
* at this time, we can work around it by also checking the ring entries
|
|
|
|
* separately and ensuring that they have not changed.
|
|
|
|
*/
|
|
|
|
ring_count = rte_mempool_ops_get_count(mp);
|
|
|
|
if (rte_mempool_full(mp) && rte_mempool_ops_get_count(mp) == ring_count) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free unused mempools. */
|
|
|
|
static void
|
|
|
|
dpdk_mp_sweep(void)
|
|
|
|
{
|
|
|
|
struct dpdk_mp *dmp, *next;
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dpdk_mp_mutex);
|
|
|
|
LIST_FOR_EACH_SAFE (dmp, next, list_node, &dpdk_mp_free_list) {
|
|
|
|
if (dpdk_mp_full(dmp->mp)) {
|
|
|
|
VLOG_DBG("Freeing mempool \"%s\"", dmp->mp->name);
|
|
|
|
ovs_list_remove(&dmp->list_node);
|
|
|
|
rte_mempool_free(dmp->mp);
|
|
|
|
rte_free(dmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ovs_mutex_unlock(&dpdk_mp_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ensure a mempool will not be freed. */
|
|
|
|
static void
|
|
|
|
dpdk_mp_do_not_free(struct rte_mempool *mp) OVS_REQUIRES(dpdk_mp_mutex)
|
|
|
|
{
|
|
|
|
struct dpdk_mp *dmp, *next;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE (dmp, next, list_node, &dpdk_mp_free_list) {
|
|
|
|
if (dmp->mp == mp) {
|
|
|
|
VLOG_DBG("Removing mempool \"%s\" from free list", dmp->mp->name);
|
|
|
|
ovs_list_remove(&dmp->list_node);
|
|
|
|
rte_free(dmp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-10 18:16:11 +03:00
|
|
|
/* Returns a valid pointer when either of the following is true:
|
|
|
|
* - a new mempool was just created;
|
|
|
|
* - a matching mempool already exists. */
|
|
|
|
static struct rte_mempool *
|
|
|
|
dpdk_mp_create(struct netdev_dpdk *dev, int mtu)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
2017-11-10 18:16:11 +03:00
|
|
|
char mp_name[RTE_MEMPOOL_NAMESIZE];
|
|
|
|
const char *netdev_name = netdev_get_name(&dev->up);
|
|
|
|
int socket_id = dev->requested_socket_id;
|
|
|
|
uint32_t n_mbufs;
|
|
|
|
uint32_t hash = hash_string(netdev_name, 0);
|
|
|
|
struct rte_mempool *mp = NULL;
|
2017-09-01 13:40:25 -07:00
|
|
|
|
|
|
|
/*
|
2017-10-19 17:54:07 +01:00
|
|
|
* XXX: rough estimation of number of mbufs required for this port:
|
2017-09-01 13:40:25 -07:00
|
|
|
* <packets required to fill the device rxqs>
|
|
|
|
* + <packets that could be stuck on other ports txqs>
|
|
|
|
* + <packets in the pmd threads>
|
|
|
|
* + <additional memory for corner cases>
|
2016-08-09 17:01:20 +01:00
|
|
|
*/
|
2017-11-10 18:16:11 +03:00
|
|
|
n_mbufs = dev->requested_n_rxq * dev->requested_rxq_size
|
|
|
|
+ dev->requested_n_txq * dev->requested_txq_size
|
|
|
|
+ MIN(RTE_MAX_LCORE, dev->requested_n_rxq) * NETDEV_MAX_BURST
|
|
|
|
+ MIN_NB_MBUF;
|
2017-09-01 13:40:25 -07:00
|
|
|
|
2017-11-10 18:16:11 +03:00
|
|
|
ovs_mutex_lock(&dpdk_mp_mutex);
|
2015-03-12 18:04:32 +00:00
|
|
|
do {
|
2017-11-10 18:16:11 +03:00
|
|
|
/* Full DPDK memory pool name must be unique and cannot be
|
|
|
|
* longer than RTE_MEMPOOL_NAMESIZE. */
|
2017-11-10 10:12:06 +03:00
|
|
|
int ret = snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
|
|
|
|
"ovs%08x%02d%05d%07u",
|
2017-11-10 18:16:11 +03:00
|
|
|
hash, socket_id, mtu, n_mbufs);
|
|
|
|
if (ret < 0 || ret >= RTE_MEMPOOL_NAMESIZE) {
|
|
|
|
VLOG_DBG("snprintf returned %d. "
|
|
|
|
"Failed to generate a mempool name for \"%s\". "
|
|
|
|
"Hash:0x%x, socket_id: %d, mtu:%d, mbufs:%u.",
|
|
|
|
ret, netdev_name, hash, socket_id, mtu, n_mbufs);
|
|
|
|
break;
|
2017-10-19 17:54:06 +01:00
|
|
|
}
|
2014-07-11 13:37:11 +01:00
|
|
|
|
2017-10-19 17:54:04 +01:00
|
|
|
VLOG_DBG("Port %s: Requesting a mempool of %u mbufs "
|
|
|
|
"on socket %d for %d Rx and %d Tx queues.",
|
2017-11-10 18:16:11 +03:00
|
|
|
netdev_name, n_mbufs, socket_id,
|
2017-10-19 17:54:04 +01:00
|
|
|
dev->requested_n_rxq, dev->requested_n_txq);
|
2017-09-01 13:40:25 -07:00
|
|
|
|
2017-11-10 18:16:11 +03:00
|
|
|
mp = rte_pktmbuf_pool_create(mp_name, n_mbufs, MP_CACHE_SZ,
|
|
|
|
sizeof (struct dp_packet) - sizeof (struct rte_mbuf),
|
|
|
|
MBUF_SIZE(mtu) - sizeof(struct dp_packet), socket_id);
|
|
|
|
|
|
|
|
if (mp) {
|
|
|
|
VLOG_DBG("Allocated \"%s\" mempool with %u mbufs",
|
|
|
|
mp_name, n_mbufs);
|
2017-10-19 17:54:05 +01:00
|
|
|
/* rte_pktmbuf_pool_create has done some initialization of the
|
|
|
|
* rte_mbuf part of each dp_packet. Some OvS specific fields
|
|
|
|
* of the packet still need to be initialized by
|
|
|
|
* ovs_rte_pktmbuf_init. */
|
2017-11-10 18:16:11 +03:00
|
|
|
rte_mempool_obj_iter(mp, ovs_rte_pktmbuf_init, NULL);
|
2017-09-01 13:40:25 -07:00
|
|
|
} else if (rte_errno == EEXIST) {
|
|
|
|
/* A mempool with the same name already exists. We just
|
|
|
|
* retrieve its pointer to be returned to the caller. */
|
2017-11-10 18:16:11 +03:00
|
|
|
mp = rte_mempool_lookup(mp_name);
|
2017-09-01 13:40:25 -07:00
|
|
|
/* As the mempool create returned EEXIST we can expect the
|
|
|
|
* lookup has returned a valid pointer. If for some reason
|
|
|
|
* that's not the case we keep track of it. */
|
2017-11-10 18:16:11 +03:00
|
|
|
VLOG_DBG("A mempool with name \"%s\" already exists at %p.",
|
|
|
|
mp_name, mp);
|
2018-04-13 18:40:13 +01:00
|
|
|
/* Ensure this reused mempool will not be freed. */
|
|
|
|
dpdk_mp_do_not_free(mp);
|
2017-09-01 13:40:25 -07:00
|
|
|
} else {
|
|
|
|
VLOG_ERR("Failed mempool \"%s\" create request of %u mbufs",
|
2017-11-10 18:16:11 +03:00
|
|
|
mp_name, n_mbufs);
|
2016-10-04 17:58:05 -07:00
|
|
|
}
|
2017-11-10 18:16:11 +03:00
|
|
|
} while (!mp && rte_errno == ENOMEM && (n_mbufs /= 2) >= MIN_NB_MBUF);
|
2016-10-04 17:58:05 -07:00
|
|
|
|
2016-09-23 16:17:58 +03:00
|
|
|
ovs_mutex_unlock(&dpdk_mp_mutex);
|
2017-11-10 18:16:11 +03:00
|
|
|
return mp;
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
|
2017-10-19 17:54:08 +01:00
|
|
|
/* Release an existing mempool. */
|
2014-03-24 19:23:08 -07:00
|
|
|
static void
|
2018-04-13 18:40:13 +01:00
|
|
|
dpdk_mp_release(struct rte_mempool *mp)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
2017-11-10 18:16:11 +03:00
|
|
|
if (!mp) {
|
2014-03-24 19:23:08 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-23 16:17:58 +03:00
|
|
|
ovs_mutex_lock(&dpdk_mp_mutex);
|
2018-04-13 18:40:13 +01:00
|
|
|
if (dpdk_mp_full(mp)) {
|
|
|
|
VLOG_DBG("Freeing mempool \"%s\"", mp->name);
|
|
|
|
rte_mempool_free(mp);
|
|
|
|
} else {
|
|
|
|
struct dpdk_mp *dmp;
|
|
|
|
|
|
|
|
dmp = dpdk_rte_mzalloc(sizeof *dmp);
|
|
|
|
if (dmp) {
|
|
|
|
dmp->mp = mp;
|
|
|
|
ovs_list_push_back(&dpdk_mp_free_list, &dmp->list_node);
|
|
|
|
}
|
|
|
|
}
|
2016-09-23 16:17:58 +03:00
|
|
|
ovs_mutex_unlock(&dpdk_mp_mutex);
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
|
2017-10-19 17:54:03 +01:00
|
|
|
/* Tries to allocate a new mempool - or re-use an existing one where
|
|
|
|
* appropriate - on requested_socket_id with a size determined by
|
|
|
|
* requested_mtu and requested Rx/Tx queues.
|
|
|
|
* On success - or when re-using an existing mempool - the new configuration
|
|
|
|
* will be applied.
|
2016-08-09 17:01:20 +01:00
|
|
|
* On error, device will be left unchanged. */
|
|
|
|
static int
|
|
|
|
netdev_dpdk_mempool_configure(struct netdev_dpdk *dev)
|
|
|
|
OVS_REQUIRES(dev->mutex)
|
|
|
|
{
|
|
|
|
uint32_t buf_size = dpdk_buf_size(dev->requested_mtu);
|
2017-11-10 18:16:11 +03:00
|
|
|
struct rte_mempool *mp;
|
|
|
|
int ret = 0;
|
2016-08-09 17:01:20 +01:00
|
|
|
|
2018-04-13 18:40:13 +01:00
|
|
|
dpdk_mp_sweep();
|
|
|
|
|
2017-11-10 18:16:11 +03:00
|
|
|
mp = dpdk_mp_create(dev, FRAME_LEN_TO_MTU(buf_size));
|
2016-08-09 17:01:20 +01:00
|
|
|
if (!mp) {
|
2017-03-13 11:35:26 +00:00
|
|
|
VLOG_ERR("Failed to create memory pool for netdev "
|
|
|
|
"%s, with MTU %d on socket %d: %s\n",
|
|
|
|
dev->up.name, dev->requested_mtu, dev->requested_socket_id,
|
|
|
|
rte_strerror(rte_errno));
|
2017-11-10 18:16:11 +03:00
|
|
|
ret = rte_errno;
|
2016-08-09 17:01:20 +01:00
|
|
|
} else {
|
2017-11-10 18:16:11 +03:00
|
|
|
/* If a new MTU was requested and its rounded value equals the one
|
|
|
|
* that is currently used, then the existing mempool is returned. */
|
|
|
|
if (dev->mp != mp) {
|
|
|
|
/* A new mempool was created, release the previous one. */
|
2018-04-13 18:40:13 +01:00
|
|
|
dpdk_mp_release(dev->mp);
|
2017-11-10 18:16:11 +03:00
|
|
|
} else {
|
|
|
|
ret = EEXIST;
|
|
|
|
}
|
|
|
|
dev->mp = mp;
|
2016-08-09 17:01:20 +01:00
|
|
|
dev->mtu = dev->requested_mtu;
|
|
|
|
dev->socket_id = dev->requested_socket_id;
|
|
|
|
dev->max_packet_len = MTU_TO_FRAME_LEN(dev->mtu);
|
|
|
|
}
|
|
|
|
|
2017-11-10 18:16:11 +03:00
|
|
|
return ret;
|
2016-08-09 17:01:20 +01:00
|
|
|
}
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
static void
|
|
|
|
check_link_status(struct netdev_dpdk *dev)
|
|
|
|
{
|
|
|
|
struct rte_eth_link link;
|
|
|
|
|
|
|
|
rte_eth_link_get_nowait(dev->port_id, &link);
|
|
|
|
|
|
|
|
if (dev->link.link_status != link.link_status) {
|
2014-04-03 00:17:34 -07:00
|
|
|
netdev_change_seq_changed(&dev->up);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
|
|
|
dev->link_reset_cnt++;
|
|
|
|
dev->link = link;
|
|
|
|
if (dev->link.link_status) {
|
2018-02-21 17:39:35 +03:00
|
|
|
VLOG_DBG_RL(&rl,
|
|
|
|
"Port "DPDK_PORT_ID_FMT" Link Up - speed %u Mbps - %s",
|
2016-09-29 11:27:03 +01:00
|
|
|
dev->port_id, (unsigned) dev->link.link_speed,
|
2018-02-21 17:39:35 +03:00
|
|
|
(dev->link.link_duplex == ETH_LINK_FULL_DUPLEX)
|
|
|
|
? "full-duplex" : "half-duplex");
|
2014-03-24 19:23:08 -07:00
|
|
|
} else {
|
2018-02-21 17:39:35 +03:00
|
|
|
VLOG_DBG_RL(&rl, "Port "DPDK_PORT_ID_FMT" Link Down",
|
|
|
|
dev->port_id);
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
dpdk_watchdog(void *dummy OVS_UNUSED)
|
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev;
|
|
|
|
|
|
|
|
pthread_detach(pthread_self());
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
ovs_mutex_lock(&dpdk_mutex);
|
|
|
|
LIST_FOR_EACH (dev, list_node, &dpdk_list) {
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
2016-06-24 16:28:32 +03:00
|
|
|
if (dev->type == DPDK_DEV_ETH) {
|
|
|
|
check_link_status(dev);
|
|
|
|
}
|
2014-03-24 19:23:08 -07:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
}
|
|
|
|
ovs_mutex_unlock(&dpdk_mutex);
|
|
|
|
xsleep(DPDK_PORT_WATCHDOG_INTERVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-07-16 19:48:24 +01:00
|
|
|
static int
|
2018-04-23 11:42:41 +00:00
|
|
|
dpdk_eth_dev_port_config(struct netdev_dpdk *dev, int n_rxq, int n_txq)
|
2015-07-16 19:48:24 +01:00
|
|
|
{
|
|
|
|
int diag = 0;
|
|
|
|
int i;
|
2016-08-09 17:01:20 +01:00
|
|
|
struct rte_eth_conf conf = port_conf;
|
2018-04-27 17:40:49 +01:00
|
|
|
struct rte_eth_dev_info info;
|
|
|
|
|
|
|
|
/* As of DPDK 17.11.1 a few PMDs require to explicitly enable
|
|
|
|
* scatter to support jumbo RX. Checking the offload capabilities
|
|
|
|
* is not an option as PMDs are not required yet to report
|
|
|
|
* them. The only reliable info is the driver name and knowledge
|
|
|
|
* (testing or code review). Listing all such PMDs feels harder
|
|
|
|
* than highlighting the one known not to need scatter */
|
2016-08-09 17:01:20 +01:00
|
|
|
if (dev->mtu > ETHER_MTU) {
|
2018-04-27 17:40:49 +01:00
|
|
|
rte_eth_dev_info_get(dev->port_id, &info);
|
|
|
|
if (strncmp(info.driver_name, "net_nfp", 6)) {
|
|
|
|
conf.rxmode.enable_scatter = 1;
|
|
|
|
}
|
2016-08-09 17:01:20 +01:00
|
|
|
}
|
2017-08-01 15:03:08 -07:00
|
|
|
|
2018-04-23 11:42:41 +00:00
|
|
|
conf.intr_conf.lsc = dev->lsc_interrupt_mode;
|
netdev-dpdk: Enable Rx checksum offloading feature on DPDK physical ports.
Add Rx checksum offloading feature support on DPDK physical ports. By default,
the Rx checksum offloading is enabled if NIC supports. However,
the checksum offloading can be turned OFF either while adding a new DPDK
physical port to OVS or at runtime.
The rx checksum offloading can be turned off by setting the parameter to
'false'. For eg: To disable the rx checksum offloading when adding a port,
'ovs-vsctl add-port br0 dpdk0 -- \
set Interface dpdk0 type=dpdk options:rx-checksum-offload=false'
OR (to disable at run time after port is being added to OVS)
'ovs-vsctl set Interface dpdk0 options:rx-checksum-offload=false'
Similarly to turn ON rx checksum offloading at run time,
'ovs-vsctl set Interface dpdk0 options:rx-checksum-offload=true'
The Tx checksum offloading support is not implemented due to the following
reasons.
1) Checksum offloading and vectorization are mutually exclusive in DPDK poll
mode driver. Vector packet processing is turned OFF when checksum offloading
is enabled which causes significant performance drop at Tx side.
2) Normally, OVS generates checksum for tunnel packets in software at the
'tunnel push' operation, where the tunnel headers are created. However
enabling Tx checksum offloading involves,
*) Mark every packets for tx checksum offloading at 'tunnel_push' and
recirculate.
*) At the time of xmit, validate the same flag and instruct the NIC to do the
checksum calculation. In case NIC doesnt support Tx checksum offloading,
the checksum calculation has to be done in software before sending out the
packets.
No significant performance improvement noticed with Tx checksum offloading
due to the e overhead of additional validations + non vector packet processing.
In some test scenarios, it introduces performance drop too.
Rx checksum offloading still offers 8-9% of improvement on VxLAN tunneling
decapsulation even though the SSE vector Rx function is disabled in DPDK poll
mode driver.
Signed-off-by: Sugesh Chandran <sugesh.chandran@intel.com>
Acked-by: Jesse Gross <jesse@kernel.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
2017-01-02 14:27:48 -08:00
|
|
|
conf.rxmode.hw_ip_checksum = (dev->hw_ol_features &
|
|
|
|
NETDEV_RX_CHECKSUM_OFFLOAD) != 0;
|
2015-07-16 19:48:24 +01:00
|
|
|
/* A device may report more queues than it makes available (this has
|
|
|
|
* been observed for Intel xl710, which reserves some of them for
|
|
|
|
* SRIOV): rte_eth_*_queue_setup will fail if a queue is not
|
|
|
|
* available. When this happens we can retry the configuration
|
|
|
|
* and request less queues */
|
|
|
|
while (n_rxq && n_txq) {
|
|
|
|
if (diag) {
|
|
|
|
VLOG_INFO("Retrying setup with (rxq:%d txq:%d)", n_rxq, n_txq);
|
|
|
|
}
|
|
|
|
|
2016-08-09 17:01:20 +01:00
|
|
|
diag = rte_eth_dev_configure(dev->port_id, n_rxq, n_txq, &conf);
|
2015-07-16 19:48:24 +01:00
|
|
|
if (diag) {
|
2016-08-09 17:01:20 +01:00
|
|
|
VLOG_WARN("Interface %s eth_dev setup error %s\n",
|
|
|
|
dev->up.name, rte_strerror(-diag));
|
2015-07-16 19:48:24 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-08-01 15:03:08 -07:00
|
|
|
diag = rte_eth_dev_set_mtu(dev->port_id, dev->mtu);
|
|
|
|
if (diag) {
|
|
|
|
VLOG_ERR("Interface %s MTU (%d) setup error: %s",
|
|
|
|
dev->up.name, dev->mtu, rte_strerror(-diag));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-07-16 19:48:24 +01:00
|
|
|
for (i = 0; i < n_txq; i++) {
|
2016-09-30 14:50:53 +01:00
|
|
|
diag = rte_eth_tx_queue_setup(dev->port_id, i, dev->txq_size,
|
2015-07-16 19:48:24 +01:00
|
|
|
dev->socket_id, NULL);
|
|
|
|
if (diag) {
|
2018-03-22 17:20:58 +00:00
|
|
|
VLOG_INFO("Interface %s unable to setup txq(%d): %s",
|
2015-07-16 19:48:24 +01:00
|
|
|
dev->up.name, i, rte_strerror(-diag));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i != n_txq) {
|
|
|
|
/* Retry with less tx queues */
|
|
|
|
n_txq = i;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < n_rxq; i++) {
|
2016-09-30 14:50:53 +01:00
|
|
|
diag = rte_eth_rx_queue_setup(dev->port_id, i, dev->rxq_size,
|
2017-11-10 18:16:11 +03:00
|
|
|
dev->socket_id, NULL, dev->mp);
|
2015-07-16 19:48:24 +01:00
|
|
|
if (diag) {
|
2018-03-22 17:20:58 +00:00
|
|
|
VLOG_INFO("Interface %s unable to setup rxq(%d): %s",
|
2015-07-16 19:48:24 +01:00
|
|
|
dev->up.name, i, rte_strerror(-diag));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i != n_rxq) {
|
|
|
|
/* Retry with less rx queues */
|
|
|
|
n_rxq = i;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev->up.n_rxq = n_rxq;
|
2016-07-08 16:52:37 +03:00
|
|
|
dev->up.n_txq = n_txq;
|
2015-07-16 19:48:24 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return diag;
|
|
|
|
}
|
|
|
|
|
2016-07-28 16:30:12 +01:00
|
|
|
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)) {
|
2018-02-21 17:39:35 +03:00
|
|
|
VLOG_WARN("Failed to enable flow control on device "DPDK_PORT_ID_FMT,
|
2017-05-19 16:37:32 +03:00
|
|
|
dev->port_id);
|
2016-07-28 16:30:12 +01:00
|
|
|
}
|
|
|
|
}
|
2015-07-16 19:48:24 +01:00
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
static int
|
2016-09-23 16:17:58 +03:00
|
|
|
dpdk_eth_dev_init(struct netdev_dpdk *dev)
|
|
|
|
OVS_REQUIRES(dev->mutex)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
|
|
|
struct rte_pktmbuf_pool_private *mbp_priv;
|
2015-05-22 17:14:22 +01:00
|
|
|
struct rte_eth_dev_info info;
|
2014-03-24 19:23:08 -07:00
|
|
|
struct ether_addr eth_addr;
|
|
|
|
int diag;
|
2015-07-16 19:48:24 +01:00
|
|
|
int n_rxq, n_txq;
|
2017-06-26 22:51:50 +01:00
|
|
|
uint32_t rx_chksm_offload_capa = DEV_RX_OFFLOAD_UDP_CKSUM |
|
|
|
|
DEV_RX_OFFLOAD_TCP_CKSUM |
|
|
|
|
DEV_RX_OFFLOAD_IPV4_CKSUM;
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2015-05-22 17:14:22 +01:00
|
|
|
rte_eth_dev_info_get(dev->port_id, &info);
|
|
|
|
|
2017-06-26 22:51:50 +01:00
|
|
|
if ((info.rx_offload_capa & rx_chksm_offload_capa) !=
|
|
|
|
rx_chksm_offload_capa) {
|
2018-02-21 17:39:35 +03:00
|
|
|
VLOG_WARN("Rx checksum offload is not supported on port "
|
|
|
|
DPDK_PORT_ID_FMT, dev->port_id);
|
2017-06-26 22:51:50 +01:00
|
|
|
dev->hw_ol_features &= ~NETDEV_RX_CHECKSUM_OFFLOAD;
|
|
|
|
} else {
|
|
|
|
dev->hw_ol_features |= NETDEV_RX_CHECKSUM_OFFLOAD;
|
|
|
|
}
|
|
|
|
|
2015-07-16 19:48:24 +01:00
|
|
|
n_rxq = MIN(info.max_rx_queues, dev->up.n_rxq);
|
|
|
|
n_txq = MIN(info.max_tx_queues, dev->up.n_txq);
|
|
|
|
|
2018-04-23 11:42:41 +00:00
|
|
|
diag = dpdk_eth_dev_port_config(dev, n_rxq, n_txq);
|
2014-03-24 19:23:08 -07:00
|
|
|
if (diag) {
|
2018-04-23 11:42:41 +00:00
|
|
|
VLOG_ERR("Interface %s(rxq:%d txq:%d lsc interrupt mode:%s) "
|
|
|
|
"configure error: %s",
|
|
|
|
dev->up.name, n_rxq, n_txq,
|
|
|
|
dev->lsc_interrupt_mode ? "true" : "false",
|
|
|
|
rte_strerror(-diag));
|
2014-07-11 13:37:11 +01:00
|
|
|
return -diag;
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
diag = rte_eth_dev_start(dev->port_id);
|
|
|
|
if (diag) {
|
2015-07-16 19:48:24 +01:00
|
|
|
VLOG_ERR("Interface %s start error: %s", dev->up.name,
|
|
|
|
rte_strerror(-diag));
|
2014-07-11 13:37:11 +01:00
|
|
|
return -diag;
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
rte_eth_promiscuous_enable(dev->port_id);
|
|
|
|
rte_eth_allmulticast_enable(dev->port_id);
|
|
|
|
|
|
|
|
memset(ð_addr, 0x0, sizeof(eth_addr));
|
|
|
|
rte_eth_macaddr_get(dev->port_id, ð_addr);
|
2018-02-21 17:39:35 +03:00
|
|
|
VLOG_INFO_RL(&rl, "Port "DPDK_PORT_ID_FMT": "ETH_ADDR_FMT,
|
|
|
|
dev->port_id, ETH_ADDR_BYTES_ARGS(eth_addr.addr_bytes));
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2015-09-04 16:53:30 -04:00
|
|
|
memcpy(dev->hwaddr.ea, eth_addr.addr_bytes, ETH_ADDR_LEN);
|
2014-03-24 19:23:08 -07:00
|
|
|
rte_eth_link_get_nowait(dev->port_id, &dev->link);
|
|
|
|
|
2017-11-10 18:16:11 +03:00
|
|
|
mbp_priv = rte_mempool_get_priv(dev->mp);
|
2014-03-24 19:23:08 -07:00
|
|
|
dev->buf_size = mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM;
|
|
|
|
|
2016-07-28 16:30:12 +01:00
|
|
|
/* Get the Flow control configuration for DPDK-ETH */
|
|
|
|
diag = rte_eth_dev_flow_ctrl_get(dev->port_id, &dev->fc_conf);
|
|
|
|
if (diag) {
|
2018-02-21 17:39:35 +03:00
|
|
|
VLOG_DBG("cannot get flow control parameters on port "DPDK_PORT_ID_FMT
|
|
|
|
", err=%d", dev->port_id, diag);
|
2016-07-28 16:30:12 +01:00
|
|
|
}
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct netdev_dpdk *
|
|
|
|
netdev_dpdk_cast(const struct netdev *netdev)
|
|
|
|
{
|
|
|
|
return CONTAINER_OF(netdev, struct netdev_dpdk, up);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct netdev *
|
|
|
|
netdev_dpdk_alloc(void)
|
|
|
|
{
|
2016-04-29 13:44:01 -04:00
|
|
|
struct netdev_dpdk *dev;
|
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
dev = dpdk_rte_mzalloc(sizeof *dev);
|
|
|
|
if (dev) {
|
|
|
|
return &dev->up;
|
2016-04-29 13:44:01 -04:00
|
|
|
}
|
2016-10-04 17:58:05 -07:00
|
|
|
|
2016-04-29 13:44:01 -04:00
|
|
|
return NULL;
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
static struct dpdk_tx_queue *
|
|
|
|
netdev_dpdk_alloc_txq(unsigned int n_txqs)
|
2014-06-17 10:52:20 -07:00
|
|
|
{
|
2016-10-04 17:58:05 -07:00
|
|
|
struct dpdk_tx_queue *txqs;
|
2015-05-22 17:14:19 +01:00
|
|
|
unsigned i;
|
2014-06-17 10:52:20 -07:00
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
txqs = dpdk_rte_mzalloc(n_txqs * sizeof *txqs);
|
|
|
|
if (txqs) {
|
|
|
|
for (i = 0; i < n_txqs; i++) {
|
|
|
|
/* Initialize map for vhost devices. */
|
|
|
|
txqs[i].map = OVS_VHOST_QUEUE_MAP_UNKNOWN;
|
|
|
|
rte_spinlock_init(&txqs[i].tx_lock);
|
|
|
|
}
|
2014-06-17 10:52:20 -07:00
|
|
|
}
|
2016-10-04 17:58:05 -07:00
|
|
|
|
|
|
|
return txqs;
|
2014-06-17 10:52:20 -07:00
|
|
|
}
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
static int
|
2017-05-19 16:37:32 +03:00
|
|
|
common_construct(struct netdev *netdev, dpdk_port_t port_no,
|
2016-11-15 15:40:49 -08:00
|
|
|
enum dpdk_dev_type type, int socket_id)
|
2014-06-17 10:52:20 -07:00
|
|
|
OVS_REQUIRES(dpdk_mutex)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2016-03-16 14:44:18 -07:00
|
|
|
ovs_mutex_init(&dev->mutex);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2016-03-16 14:44:18 -07:00
|
|
|
rte_spinlock_init(&dev->stats_lock);
|
2015-05-22 17:14:21 +01:00
|
|
|
|
2014-09-25 13:10:55 -07:00
|
|
|
/* If the 'sid' is negative, it means that the kernel fails
|
|
|
|
* to obtain the pci numa info. In that situation, always
|
|
|
|
* use 'SOCKET0'. */
|
2016-11-15 15:40:49 -08:00
|
|
|
dev->socket_id = socket_id < 0 ? SOCKET0 : socket_id;
|
2016-06-13 11:10:09 +01:00
|
|
|
dev->requested_socket_id = dev->socket_id;
|
2016-03-16 14:44:18 -07:00
|
|
|
dev->port_id = port_no;
|
|
|
|
dev->type = type;
|
|
|
|
dev->flags = 0;
|
2016-11-15 15:40:49 -08:00
|
|
|
dev->requested_mtu = ETHER_MTU;
|
2016-03-16 14:44:18 -07:00
|
|
|
dev->max_packet_len = MTU_TO_FRAME_LEN(dev->mtu);
|
2018-04-23 11:42:41 +00:00
|
|
|
dev->requested_lsc_interrupt_mode = 0;
|
2016-08-03 13:29:24 +01:00
|
|
|
ovsrcu_index_init(&dev->vid, -1);
|
|
|
|
dev->vhost_reconfigured = false;
|
2017-05-19 16:37:31 +03:00
|
|
|
dev->attached = false;
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
ovsrcu_init(&dev->qos_conf, NULL);
|
2016-03-02 20:35:54 +00:00
|
|
|
|
2016-05-24 17:36:51 +01:00
|
|
|
ovsrcu_init(&dev->ingress_policer, NULL);
|
|
|
|
dev->policer_rate = 0;
|
|
|
|
dev->policer_burst = 0;
|
|
|
|
|
2016-11-15 15:40:49 -08:00
|
|
|
netdev->n_rxq = 0;
|
|
|
|
netdev->n_txq = 0;
|
|
|
|
dev->requested_n_rxq = NR_QUEUE;
|
|
|
|
dev->requested_n_txq = NR_QUEUE;
|
|
|
|
dev->requested_rxq_size = NIC_PORT_DEFAULT_RXQ_SIZE;
|
|
|
|
dev->requested_txq_size = NIC_PORT_DEFAULT_TXQ_SIZE;
|
2015-03-05 13:42:04 -08:00
|
|
|
|
2016-07-28 16:30:12 +01:00
|
|
|
/* Initialize the flow control to NULL */
|
|
|
|
memset(&dev->fc_conf, 0, sizeof dev->fc_conf);
|
netdev-dpdk: Enable Rx checksum offloading feature on DPDK physical ports.
Add Rx checksum offloading feature support on DPDK physical ports. By default,
the Rx checksum offloading is enabled if NIC supports. However,
the checksum offloading can be turned OFF either while adding a new DPDK
physical port to OVS or at runtime.
The rx checksum offloading can be turned off by setting the parameter to
'false'. For eg: To disable the rx checksum offloading when adding a port,
'ovs-vsctl add-port br0 dpdk0 -- \
set Interface dpdk0 type=dpdk options:rx-checksum-offload=false'
OR (to disable at run time after port is being added to OVS)
'ovs-vsctl set Interface dpdk0 options:rx-checksum-offload=false'
Similarly to turn ON rx checksum offloading at run time,
'ovs-vsctl set Interface dpdk0 options:rx-checksum-offload=true'
The Tx checksum offloading support is not implemented due to the following
reasons.
1) Checksum offloading and vectorization are mutually exclusive in DPDK poll
mode driver. Vector packet processing is turned OFF when checksum offloading
is enabled which causes significant performance drop at Tx side.
2) Normally, OVS generates checksum for tunnel packets in software at the
'tunnel push' operation, where the tunnel headers are created. However
enabling Tx checksum offloading involves,
*) Mark every packets for tx checksum offloading at 'tunnel_push' and
recirculate.
*) At the time of xmit, validate the same flag and instruct the NIC to do the
checksum calculation. In case NIC doesnt support Tx checksum offloading,
the checksum calculation has to be done in software before sending out the
packets.
No significant performance improvement noticed with Tx checksum offloading
due to the e overhead of additional validations + non vector packet processing.
In some test scenarios, it introduces performance drop too.
Rx checksum offloading still offers 8-9% of improvement on VxLAN tunneling
decapsulation even though the SSE vector Rx function is disabled in DPDK poll
mode driver.
Signed-off-by: Sugesh Chandran <sugesh.chandran@intel.com>
Acked-by: Jesse Gross <jesse@kernel.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
2017-01-02 14:27:48 -08:00
|
|
|
|
|
|
|
/* Initilize the hardware offload flags to 0 */
|
|
|
|
dev->hw_ol_features = 0;
|
2016-11-15 15:40:49 -08:00
|
|
|
|
|
|
|
dev->flags = NETDEV_UP | NETDEV_PROMISC;
|
|
|
|
|
2016-03-16 14:44:18 -07:00
|
|
|
ovs_list_push_back(&dpdk_list, &dev->list_node);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2016-11-15 15:40:49 -08:00
|
|
|
netdev_request_reconfigure(netdev);
|
|
|
|
|
2018-01-09 07:55:37 +00:00
|
|
|
dev->rte_xstats_names = NULL;
|
|
|
|
dev->rte_xstats_names_size = 0;
|
|
|
|
|
|
|
|
dev->rte_xstats_ids = NULL;
|
|
|
|
dev->rte_xstats_ids_size = 0;
|
|
|
|
|
2016-11-15 15:40:49 -08:00
|
|
|
return 0;
|
2014-07-11 13:37:11 +01:00
|
|
|
}
|
|
|
|
|
2016-02-23 23:06:37 +01:00
|
|
|
/* dev_name must be the prefix followed by a positive decimal number.
|
|
|
|
* (no leading + or - signs are allowed) */
|
2014-07-11 13:37:11 +01:00
|
|
|
static int
|
|
|
|
dpdk_dev_parse_name(const char dev_name[], const char prefix[],
|
|
|
|
unsigned int *port_no)
|
|
|
|
{
|
|
|
|
const char *cport;
|
|
|
|
|
|
|
|
if (strncmp(dev_name, prefix, strlen(prefix))) {
|
|
|
|
return ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
cport = dev_name + strlen(prefix);
|
2016-02-23 23:06:37 +01:00
|
|
|
|
|
|
|
if (str_to_uint(cport, 10, port_no)) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return ENODEV;
|
|
|
|
}
|
2014-07-11 13:37:11 +01:00
|
|
|
}
|
|
|
|
|
2016-11-15 15:40:49 -08:00
|
|
|
static int
|
|
|
|
vhost_common_construct(struct netdev *netdev)
|
|
|
|
OVS_REQUIRES(dpdk_mutex)
|
|
|
|
{
|
|
|
|
int socket_id = rte_lcore_to_socket_id(rte_get_master_lcore());
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
|
|
|
|
|
|
|
dev->tx_q = netdev_dpdk_alloc_txq(OVS_VHOST_MAX_QUEUE_NUM);
|
|
|
|
if (!dev->tx_q) {
|
|
|
|
return ENOMEM;
|
|
|
|
}
|
|
|
|
|
2017-05-19 16:37:32 +03:00
|
|
|
return common_construct(netdev, DPDK_ETH_PORT_ID_INVALID,
|
|
|
|
DPDK_DEV_VHOST, socket_id);
|
2016-11-15 15:40:49 -08:00
|
|
|
}
|
|
|
|
|
2015-06-04 06:51:40 -07:00
|
|
|
static int
|
2016-08-15 16:11:25 +01:00
|
|
|
netdev_dpdk_vhost_construct(struct netdev *netdev)
|
2015-06-04 06:51:40 -07:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
|
|
|
const char *name = netdev->name;
|
2015-06-04 06:51:40 -07:00
|
|
|
int err;
|
2015-05-22 17:14:22 +01:00
|
|
|
|
2016-02-02 17:24:32 -08:00
|
|
|
/* 'name' is appended to 'vhost_sock_dir' and used to create a socket in
|
|
|
|
* the file system. '/' or '\' would traverse directories, so they're not
|
|
|
|
* acceptable in 'name'. */
|
|
|
|
if (strchr(name, '/') || strchr(name, '\\')) {
|
|
|
|
VLOG_ERR("\"%s\" is not a valid name for a vhost-user port. "
|
|
|
|
"A valid name must not include '/' or '\\'",
|
|
|
|
name);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
2015-06-04 06:51:40 -07:00
|
|
|
ovs_mutex_lock(&dpdk_mutex);
|
|
|
|
/* Take the name of the vhost-user port and append it to the location where
|
2016-08-19 10:22:30 +01:00
|
|
|
* the socket is to be created, then register the socket.
|
2015-06-04 06:51:40 -07:00
|
|
|
*/
|
2016-08-19 10:22:30 +01:00
|
|
|
snprintf(dev->vhost_id, sizeof dev->vhost_id, "%s/%s",
|
2016-10-04 17:58:05 -07:00
|
|
|
dpdk_get_vhost_sock_dir(), name);
|
2016-02-02 17:24:32 -08:00
|
|
|
|
2016-08-19 10:22:30 +01:00
|
|
|
dev->vhost_driver_flags &= ~RTE_VHOST_USER_CLIENT;
|
|
|
|
err = rte_vhost_driver_register(dev->vhost_id, dev->vhost_driver_flags);
|
2015-06-04 06:51:40 -07:00
|
|
|
if (err) {
|
|
|
|
VLOG_ERR("vhost-user socket device setup failure for socket %s\n",
|
2016-08-19 10:22:30 +01:00
|
|
|
dev->vhost_id);
|
2017-08-01 16:14:10 -07:00
|
|
|
goto out;
|
2016-02-02 14:02:15 +03:00
|
|
|
} else {
|
2016-08-19 10:22:30 +01:00
|
|
|
fatal_signal_add_file_to_unlink(dev->vhost_id);
|
|
|
|
VLOG_INFO("Socket %s created for vhost-user port %s\n",
|
|
|
|
dev->vhost_id, name);
|
|
|
|
}
|
2017-08-01 16:14:10 -07:00
|
|
|
|
|
|
|
err = rte_vhost_driver_callback_register(dev->vhost_id,
|
|
|
|
&virtio_net_device_ops);
|
|
|
|
if (err) {
|
|
|
|
VLOG_ERR("rte_vhost_driver_callback_register failed for vhost user "
|
|
|
|
"port: %s\n", name);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = rte_vhost_driver_disable_features(dev->vhost_id,
|
|
|
|
1ULL << VIRTIO_NET_F_HOST_TSO4
|
|
|
|
| 1ULL << VIRTIO_NET_F_HOST_TSO6
|
|
|
|
| 1ULL << VIRTIO_NET_F_CSUM);
|
|
|
|
if (err) {
|
|
|
|
VLOG_ERR("rte_vhost_driver_disable_features failed for vhost user "
|
|
|
|
"port: %s\n", name);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = rte_vhost_driver_start(dev->vhost_id);
|
|
|
|
if (err) {
|
|
|
|
VLOG_ERR("rte_vhost_driver_start failed for vhost user "
|
|
|
|
"port: %s\n", name);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2016-11-15 15:40:49 -08:00
|
|
|
err = vhost_common_construct(netdev);
|
2017-08-01 16:14:10 -07:00
|
|
|
if (err) {
|
|
|
|
VLOG_ERR("vhost_common_construct failed for vhost user "
|
|
|
|
"port: %s\n", name);
|
|
|
|
}
|
2016-08-19 10:22:30 +01:00
|
|
|
|
2017-08-01 16:14:10 -07:00
|
|
|
out:
|
2016-08-19 10:22:30 +01:00
|
|
|
ovs_mutex_unlock(&dpdk_mutex);
|
2017-06-08 16:41:32 -04:00
|
|
|
VLOG_WARN_ONCE("dpdkvhostuser ports are considered deprecated; "
|
|
|
|
"please migrate to dpdkvhostuserclient ports.");
|
2016-08-19 10:22:30 +01:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netdev_dpdk_vhost_client_construct(struct netdev *netdev)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dpdk_mutex);
|
2016-11-15 15:40:49 -08:00
|
|
|
err = vhost_common_construct(netdev);
|
2017-08-01 16:14:10 -07:00
|
|
|
if (err) {
|
|
|
|
VLOG_ERR("vhost_common_construct failed for vhost user client"
|
|
|
|
"port: %s\n", netdev->name);
|
|
|
|
}
|
2015-06-04 06:51:40 -07:00
|
|
|
ovs_mutex_unlock(&dpdk_mutex);
|
2015-03-05 13:42:04 -08:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2014-07-11 13:37:11 +01:00
|
|
|
static int
|
|
|
|
netdev_dpdk_construct(struct netdev *netdev)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dpdk_mutex);
|
2017-05-19 16:37:32 +03:00
|
|
|
err = common_construct(netdev, DPDK_ETH_PORT_ID_INVALID,
|
|
|
|
DPDK_DEV_ETH, SOCKET0);
|
2014-03-24 19:23:08 -07:00
|
|
|
ovs_mutex_unlock(&dpdk_mutex);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2016-11-15 15:40:49 -08:00
|
|
|
static void
|
|
|
|
common_destruct(struct netdev_dpdk *dev)
|
|
|
|
OVS_REQUIRES(dpdk_mutex)
|
|
|
|
OVS_EXCLUDED(dev->mutex)
|
|
|
|
{
|
|
|
|
rte_free(dev->tx_q);
|
2018-04-13 18:40:13 +01:00
|
|
|
dpdk_mp_release(dev->mp);
|
2016-11-15 15:40:49 -08:00
|
|
|
|
|
|
|
ovs_list_remove(&dev->list_node);
|
|
|
|
free(ovsrcu_get_protected(struct ingress_policer *,
|
|
|
|
&dev->ingress_policer));
|
|
|
|
ovs_mutex_destroy(&dev->mutex);
|
|
|
|
}
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
static void
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_destruct(struct netdev *netdev)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2017-05-19 16:37:31 +03:00
|
|
|
char devname[RTE_ETH_NAME_MAX_LEN];
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2016-08-04 10:49:12 +01:00
|
|
|
ovs_mutex_lock(&dpdk_mutex);
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
rte_eth_dev_stop(dev->port_id);
|
2017-05-19 16:37:31 +03:00
|
|
|
|
|
|
|
if (dev->attached) {
|
|
|
|
rte_eth_dev_close(dev->port_id);
|
|
|
|
if (rte_eth_dev_detach(dev->port_id, devname) < 0) {
|
|
|
|
VLOG_ERR("Device '%s' can not be detached", dev->devargs);
|
|
|
|
} else {
|
2017-08-01 17:04:29 -07:00
|
|
|
VLOG_INFO("Device '%s' has been detached", devname);
|
2017-05-19 16:37:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-23 10:51:31 +03:00
|
|
|
netdev_dpdk_clear_xstats(dev);
|
2017-01-05 10:42:09 +00:00
|
|
|
free(dev->devargs);
|
2016-11-15 15:40:49 -08:00
|
|
|
common_destruct(dev);
|
2016-08-04 10:49:12 +01:00
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
ovs_mutex_unlock(&dpdk_mutex);
|
2015-03-05 13:42:04 -08:00
|
|
|
}
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2016-08-05 13:03:59 -07:00
|
|
|
/* rte_vhost_driver_unregister() can call back destroy_device(), which will
|
|
|
|
* try to acquire 'dpdk_mutex' and possibly 'dev->mutex'. To avoid a
|
|
|
|
* deadlock, none of the mutexes must be held while calling this function. */
|
|
|
|
static int
|
2016-08-15 16:11:26 +01:00
|
|
|
dpdk_vhost_driver_unregister(struct netdev_dpdk *dev OVS_UNUSED,
|
|
|
|
char *vhost_id)
|
2016-08-05 13:03:59 -07:00
|
|
|
OVS_EXCLUDED(dpdk_mutex)
|
|
|
|
OVS_EXCLUDED(dev->mutex)
|
|
|
|
{
|
2016-08-15 16:11:26 +01:00
|
|
|
return rte_vhost_driver_unregister(vhost_id);
|
2016-08-05 13:03:59 -07:00
|
|
|
}
|
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
static void
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_vhost_destruct(struct netdev *netdev)
|
2015-03-05 13:42:04 -08:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2016-08-15 16:11:26 +01:00
|
|
|
char *vhost_id;
|
2015-03-05 13:42:04 -08:00
|
|
|
|
2016-08-04 10:49:12 +01:00
|
|
|
ovs_mutex_lock(&dpdk_mutex);
|
|
|
|
|
2016-03-22 15:42:03 +03:00
|
|
|
/* Guest becomes an orphan if still attached. */
|
2016-08-15 16:11:26 +01:00
|
|
|
if (netdev_dpdk_get_vid(dev) >= 0
|
|
|
|
&& !(dev->vhost_driver_flags & RTE_VHOST_USER_CLIENT)) {
|
2016-03-22 15:42:03 +03:00
|
|
|
VLOG_ERR("Removing port '%s' while vhost device still attached.",
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev->name);
|
2016-09-29 11:27:03 +01:00
|
|
|
VLOG_ERR("To restore connectivity after re-adding of port, VM on "
|
|
|
|
"socket '%s' must be restarted.", dev->vhost_id);
|
2015-03-05 13:42:04 -08:00
|
|
|
}
|
|
|
|
|
2016-08-19 10:22:30 +01:00
|
|
|
vhost_id = xstrdup(dev->vhost_id);
|
2016-08-15 16:11:26 +01:00
|
|
|
|
2016-11-15 15:40:49 -08:00
|
|
|
common_destruct(dev);
|
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
ovs_mutex_unlock(&dpdk_mutex);
|
2016-08-05 13:03:59 -07:00
|
|
|
|
2016-12-06 09:45:07 +03:00
|
|
|
if (!vhost_id[0]) {
|
2016-11-29 15:20:56 +03:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2016-08-15 16:11:26 +01:00
|
|
|
if (dpdk_vhost_driver_unregister(dev, vhost_id)) {
|
2016-09-23 16:17:57 +03:00
|
|
|
VLOG_ERR("%s: Unable to unregister vhost driver for socket '%s'.\n",
|
|
|
|
netdev->name, vhost_id);
|
2016-08-15 16:11:26 +01:00
|
|
|
} else if (!(dev->vhost_driver_flags & RTE_VHOST_USER_CLIENT)) {
|
|
|
|
/* OVS server mode - remove this socket from list for deletion */
|
|
|
|
fatal_signal_remove_file_to_unlink(vhost_id);
|
2016-08-05 13:03:59 -07:00
|
|
|
}
|
2016-11-29 15:20:56 +03:00
|
|
|
out:
|
2016-08-15 16:11:26 +01:00
|
|
|
free(vhost_id);
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_dealloc(struct netdev *netdev)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2016-03-16 14:44:18 -07:00
|
|
|
rte_free(dev);
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
|
2018-01-09 07:55:37 +00:00
|
|
|
static void
|
2018-01-23 10:51:31 +03:00
|
|
|
netdev_dpdk_clear_xstats(struct netdev_dpdk *dev)
|
2018-01-09 07:55:37 +00:00
|
|
|
{
|
|
|
|
/* If statistics are already allocated, we have to
|
|
|
|
* reconfigure, as port_id could have been changed. */
|
|
|
|
if (dev->rte_xstats_names) {
|
|
|
|
free(dev->rte_xstats_names);
|
|
|
|
dev->rte_xstats_names = NULL;
|
|
|
|
dev->rte_xstats_names_size = 0;
|
|
|
|
}
|
|
|
|
if (dev->rte_xstats_ids) {
|
|
|
|
free(dev->rte_xstats_ids);
|
|
|
|
dev->rte_xstats_ids = NULL;
|
|
|
|
dev->rte_xstats_ids_size = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char*
|
|
|
|
netdev_dpdk_get_xstat_name(struct netdev_dpdk *dev, uint64_t id)
|
|
|
|
{
|
|
|
|
if (id >= dev->rte_xstats_names_size) {
|
|
|
|
return "UNKNOWN";
|
|
|
|
}
|
|
|
|
return dev->rte_xstats_names[id].name;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
netdev_dpdk_configure_xstats(struct netdev_dpdk *dev)
|
|
|
|
OVS_REQUIRES(dev->mutex)
|
|
|
|
{
|
|
|
|
int rte_xstats_len;
|
|
|
|
bool ret;
|
|
|
|
struct rte_eth_xstat *rte_xstats;
|
|
|
|
uint64_t id;
|
|
|
|
int xstats_no;
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
/* Retrieving all XSTATS names. If something will go wrong
|
|
|
|
* or amount of counters will be equal 0, rte_xstats_names
|
|
|
|
* buffer will be marked as NULL, and any further xstats
|
|
|
|
* query won't be performed (e.g. during netdev_dpdk_get_stats
|
|
|
|
* execution). */
|
|
|
|
|
|
|
|
ret = false;
|
|
|
|
rte_xstats = NULL;
|
|
|
|
|
|
|
|
if (dev->rte_xstats_names == NULL || dev->rte_xstats_ids == NULL) {
|
|
|
|
dev->rte_xstats_names_size =
|
|
|
|
rte_eth_xstats_get_names(dev->port_id, NULL, 0);
|
|
|
|
|
|
|
|
if (dev->rte_xstats_names_size < 0) {
|
2018-02-21 17:39:35 +03:00
|
|
|
VLOG_WARN("Cannot get XSTATS for port: "DPDK_PORT_ID_FMT,
|
|
|
|
dev->port_id);
|
2018-01-09 07:55:37 +00:00
|
|
|
dev->rte_xstats_names_size = 0;
|
|
|
|
} else {
|
|
|
|
/* Reserve memory for xstats names and values */
|
|
|
|
dev->rte_xstats_names = xcalloc(dev->rte_xstats_names_size,
|
|
|
|
sizeof *dev->rte_xstats_names);
|
|
|
|
|
|
|
|
if (dev->rte_xstats_names) {
|
|
|
|
/* Retreive xstats names */
|
|
|
|
rte_xstats_len =
|
|
|
|
rte_eth_xstats_get_names(dev->port_id,
|
|
|
|
dev->rte_xstats_names,
|
|
|
|
dev->rte_xstats_names_size);
|
|
|
|
|
|
|
|
if (rte_xstats_len < 0) {
|
2018-02-21 17:39:35 +03:00
|
|
|
VLOG_WARN("Cannot get XSTATS names for port: "
|
|
|
|
DPDK_PORT_ID_FMT, dev->port_id);
|
2018-01-09 07:55:37 +00:00
|
|
|
goto out;
|
|
|
|
} else if (rte_xstats_len != dev->rte_xstats_names_size) {
|
2018-02-21 17:39:35 +03:00
|
|
|
VLOG_WARN("XSTATS size doesn't match for port: "
|
|
|
|
DPDK_PORT_ID_FMT, dev->port_id);
|
2018-01-09 07:55:37 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev->rte_xstats_ids = xcalloc(dev->rte_xstats_names_size,
|
|
|
|
sizeof(uint64_t));
|
|
|
|
|
|
|
|
/* We have to calculate number of counters */
|
|
|
|
rte_xstats = xmalloc(rte_xstats_len * sizeof *rte_xstats);
|
|
|
|
memset(rte_xstats, 0xff, sizeof *rte_xstats * rte_xstats_len);
|
|
|
|
|
|
|
|
/* Retreive xstats values */
|
|
|
|
if (rte_eth_xstats_get(dev->port_id, rte_xstats,
|
|
|
|
rte_xstats_len) > 0) {
|
|
|
|
dev->rte_xstats_ids_size = 0;
|
|
|
|
xstats_no = 0;
|
|
|
|
for (uint32_t i = 0; i < rte_xstats_len; i++) {
|
|
|
|
id = rte_xstats[i].id;
|
|
|
|
name = netdev_dpdk_get_xstat_name(dev, id);
|
|
|
|
/* We need to filter out everything except
|
|
|
|
* dropped, error and management counters */
|
|
|
|
if (string_ends_with(name, "_errors") ||
|
|
|
|
strstr(name, "_management_") ||
|
|
|
|
string_ends_with(name, "_dropped")) {
|
|
|
|
|
|
|
|
dev->rte_xstats_ids[xstats_no] = id;
|
|
|
|
xstats_no++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dev->rte_xstats_ids_size = xstats_no;
|
|
|
|
ret = true;
|
|
|
|
} else {
|
2018-02-21 17:39:35 +03:00
|
|
|
VLOG_WARN("Can't get XSTATS IDs for port: "
|
|
|
|
DPDK_PORT_ID_FMT, dev->port_id);
|
2018-01-09 07:55:37 +00:00
|
|
|
}
|
2018-01-23 10:51:14 +03:00
|
|
|
|
|
|
|
free(rte_xstats);
|
2018-01-09 07:55:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Already configured */
|
|
|
|
ret = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (!ret) {
|
|
|
|
netdev_dpdk_clear_xstats(dev);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
static int
|
2016-01-21 17:15:18 +03:00
|
|
|
netdev_dpdk_get_config(const struct netdev *netdev, struct smap *args)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
2016-01-21 17:15:18 +03:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
|
2016-02-26 15:58:24 -08:00
|
|
|
smap_add_format(args, "requested_rx_queues", "%d", dev->requested_n_rxq);
|
2016-01-21 17:15:18 +03:00
|
|
|
smap_add_format(args, "configured_rx_queues", "%d", netdev->n_rxq);
|
2016-07-08 16:52:37 +03:00
|
|
|
smap_add_format(args, "requested_tx_queues", "%d", dev->requested_n_txq);
|
|
|
|
smap_add_format(args, "configured_tx_queues", "%d", netdev->n_txq);
|
2016-08-09 17:01:20 +01:00
|
|
|
smap_add_format(args, "mtu", "%d", dev->mtu);
|
2016-10-27 17:14:08 +03:00
|
|
|
|
|
|
|
if (dev->type == DPDK_DEV_ETH) {
|
|
|
|
smap_add_format(args, "requested_rxq_descriptors", "%d",
|
|
|
|
dev->requested_rxq_size);
|
|
|
|
smap_add_format(args, "configured_rxq_descriptors", "%d",
|
|
|
|
dev->rxq_size);
|
|
|
|
smap_add_format(args, "requested_txq_descriptors", "%d",
|
|
|
|
dev->requested_txq_size);
|
|
|
|
smap_add_format(args, "configured_txq_descriptors", "%d",
|
|
|
|
dev->txq_size);
|
netdev-dpdk: Enable Rx checksum offloading feature on DPDK physical ports.
Add Rx checksum offloading feature support on DPDK physical ports. By default,
the Rx checksum offloading is enabled if NIC supports. However,
the checksum offloading can be turned OFF either while adding a new DPDK
physical port to OVS or at runtime.
The rx checksum offloading can be turned off by setting the parameter to
'false'. For eg: To disable the rx checksum offloading when adding a port,
'ovs-vsctl add-port br0 dpdk0 -- \
set Interface dpdk0 type=dpdk options:rx-checksum-offload=false'
OR (to disable at run time after port is being added to OVS)
'ovs-vsctl set Interface dpdk0 options:rx-checksum-offload=false'
Similarly to turn ON rx checksum offloading at run time,
'ovs-vsctl set Interface dpdk0 options:rx-checksum-offload=true'
The Tx checksum offloading support is not implemented due to the following
reasons.
1) Checksum offloading and vectorization are mutually exclusive in DPDK poll
mode driver. Vector packet processing is turned OFF when checksum offloading
is enabled which causes significant performance drop at Tx side.
2) Normally, OVS generates checksum for tunnel packets in software at the
'tunnel push' operation, where the tunnel headers are created. However
enabling Tx checksum offloading involves,
*) Mark every packets for tx checksum offloading at 'tunnel_push' and
recirculate.
*) At the time of xmit, validate the same flag and instruct the NIC to do the
checksum calculation. In case NIC doesnt support Tx checksum offloading,
the checksum calculation has to be done in software before sending out the
packets.
No significant performance improvement noticed with Tx checksum offloading
due to the e overhead of additional validations + non vector packet processing.
In some test scenarios, it introduces performance drop too.
Rx checksum offloading still offers 8-9% of improvement on VxLAN tunneling
decapsulation even though the SSE vector Rx function is disabled in DPDK poll
mode driver.
Signed-off-by: Sugesh Chandran <sugesh.chandran@intel.com>
Acked-by: Jesse Gross <jesse@kernel.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
2017-01-02 14:27:48 -08:00
|
|
|
if (dev->hw_ol_features & NETDEV_RX_CHECKSUM_OFFLOAD) {
|
|
|
|
smap_add(args, "rx_csum_offload", "true");
|
2017-06-08 18:12:20 +01:00
|
|
|
} else {
|
|
|
|
smap_add(args, "rx_csum_offload", "false");
|
netdev-dpdk: Enable Rx checksum offloading feature on DPDK physical ports.
Add Rx checksum offloading feature support on DPDK physical ports. By default,
the Rx checksum offloading is enabled if NIC supports. However,
the checksum offloading can be turned OFF either while adding a new DPDK
physical port to OVS or at runtime.
The rx checksum offloading can be turned off by setting the parameter to
'false'. For eg: To disable the rx checksum offloading when adding a port,
'ovs-vsctl add-port br0 dpdk0 -- \
set Interface dpdk0 type=dpdk options:rx-checksum-offload=false'
OR (to disable at run time after port is being added to OVS)
'ovs-vsctl set Interface dpdk0 options:rx-checksum-offload=false'
Similarly to turn ON rx checksum offloading at run time,
'ovs-vsctl set Interface dpdk0 options:rx-checksum-offload=true'
The Tx checksum offloading support is not implemented due to the following
reasons.
1) Checksum offloading and vectorization are mutually exclusive in DPDK poll
mode driver. Vector packet processing is turned OFF when checksum offloading
is enabled which causes significant performance drop at Tx side.
2) Normally, OVS generates checksum for tunnel packets in software at the
'tunnel push' operation, where the tunnel headers are created. However
enabling Tx checksum offloading involves,
*) Mark every packets for tx checksum offloading at 'tunnel_push' and
recirculate.
*) At the time of xmit, validate the same flag and instruct the NIC to do the
checksum calculation. In case NIC doesnt support Tx checksum offloading,
the checksum calculation has to be done in software before sending out the
packets.
No significant performance improvement noticed with Tx checksum offloading
due to the e overhead of additional validations + non vector packet processing.
In some test scenarios, it introduces performance drop too.
Rx checksum offloading still offers 8-9% of improvement on VxLAN tunneling
decapsulation even though the SSE vector Rx function is disabled in DPDK poll
mode driver.
Signed-off-by: Sugesh Chandran <sugesh.chandran@intel.com>
Acked-by: Jesse Gross <jesse@kernel.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
2017-01-02 14:27:48 -08:00
|
|
|
}
|
2018-04-23 11:42:41 +00:00
|
|
|
smap_add(args, "lsc_interrupt_mode",
|
|
|
|
dev->lsc_interrupt_mode ? "true" : "false");
|
2016-10-27 17:14:08 +03:00
|
|
|
}
|
2014-03-24 19:23:08 -07:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-01-05 10:42:09 +00:00
|
|
|
static struct netdev_dpdk *
|
2017-05-19 16:37:32 +03:00
|
|
|
netdev_dpdk_lookup_by_port_id(dpdk_port_t port_id)
|
2017-01-05 10:42:09 +00:00
|
|
|
OVS_REQUIRES(dpdk_mutex)
|
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev;
|
|
|
|
|
|
|
|
LIST_FOR_EACH (dev, list_node, &dpdk_list) {
|
|
|
|
if (dev->port_id == port_id) {
|
|
|
|
return dev;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-01-10 11:05:29 +08:00
|
|
|
static dpdk_port_t
|
|
|
|
netdev_dpdk_get_port_by_mac(const char *mac_str)
|
|
|
|
{
|
|
|
|
dpdk_port_t port_id;
|
|
|
|
struct eth_addr mac, port_mac;
|
|
|
|
|
|
|
|
if (!eth_addr_from_string(mac_str, &mac)) {
|
|
|
|
VLOG_ERR("invalid mac: %s", mac_str);
|
|
|
|
return DPDK_ETH_PORT_ID_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
RTE_ETH_FOREACH_DEV (port_id) {
|
|
|
|
struct ether_addr ea;
|
|
|
|
|
|
|
|
rte_eth_macaddr_get(port_id, &ea);
|
|
|
|
memcpy(port_mac.ea, ea.addr_bytes, ETH_ADDR_LEN);
|
|
|
|
if (eth_addr_equals(mac, port_mac)) {
|
|
|
|
return port_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return DPDK_ETH_PORT_ID_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Normally, a PCI id is enough for identifying a specific DPDK port.
|
|
|
|
* However, for some NICs having multiple ports sharing the same PCI
|
|
|
|
* id, using PCI id won't work then.
|
|
|
|
*
|
|
|
|
* To fix that, here one more method is introduced: "class=eth,mac=$MAC".
|
|
|
|
*
|
|
|
|
* Note that the compatibility is fully kept: user can still use the
|
|
|
|
* PCI id for adding ports (when it's enough for them).
|
|
|
|
*/
|
2017-05-19 16:37:32 +03:00
|
|
|
static dpdk_port_t
|
2017-05-19 16:37:31 +03:00
|
|
|
netdev_dpdk_process_devargs(struct netdev_dpdk *dev,
|
|
|
|
const char *devargs, char **errp)
|
2017-01-05 10:42:09 +00:00
|
|
|
{
|
2018-01-10 11:05:29 +08:00
|
|
|
char *name;
|
2017-05-19 16:37:32 +03:00
|
|
|
dpdk_port_t new_port_id = DPDK_ETH_PORT_ID_INVALID;
|
2017-01-05 10:42:09 +00:00
|
|
|
|
2018-01-10 11:05:29 +08:00
|
|
|
if (strncmp(devargs, "class=eth,mac=", 14) == 0) {
|
|
|
|
new_port_id = netdev_dpdk_get_port_by_mac(&devargs[14]);
|
|
|
|
} else {
|
|
|
|
name = xmemdup0(devargs, strcspn(devargs, ","));
|
|
|
|
if (rte_eth_dev_get_port_by_name(name, &new_port_id)
|
|
|
|
|| !rte_eth_dev_is_valid_port(new_port_id)) {
|
|
|
|
/* Device not found in DPDK, attempt to attach it */
|
|
|
|
if (!rte_eth_dev_attach(devargs, &new_port_id)) {
|
|
|
|
/* Attach successful */
|
|
|
|
dev->attached = true;
|
|
|
|
VLOG_INFO("Device '%s' attached to DPDK", devargs);
|
|
|
|
} else {
|
|
|
|
/* Attach unsuccessful */
|
|
|
|
new_port_id = DPDK_ETH_PORT_ID_INVALID;
|
|
|
|
}
|
2017-01-05 10:42:09 +00:00
|
|
|
}
|
2018-01-10 11:05:29 +08:00
|
|
|
free(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (new_port_id == DPDK_ETH_PORT_ID_INVALID) {
|
|
|
|
VLOG_WARN_BUF(errp, "Error attaching device '%s' to DPDK", devargs);
|
2017-01-05 10:42:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return new_port_id;
|
|
|
|
}
|
|
|
|
|
2016-08-15 10:36:19 +01:00
|
|
|
static void
|
|
|
|
dpdk_set_rxq_config(struct netdev_dpdk *dev, const struct smap *args)
|
2016-09-30 10:48:45 +03:00
|
|
|
OVS_REQUIRES(dev->mutex)
|
2016-01-21 17:15:18 +03:00
|
|
|
{
|
2016-02-26 15:58:24 -08:00
|
|
|
int new_n_rxq;
|
2016-01-21 17:15:18 +03:00
|
|
|
|
2016-12-08 11:55:31 +03:00
|
|
|
new_n_rxq = MAX(smap_get_int(args, "n_rxq", NR_QUEUE), 1);
|
2016-02-26 15:58:24 -08:00
|
|
|
if (new_n_rxq != dev->requested_n_rxq) {
|
|
|
|
dev->requested_n_rxq = new_n_rxq;
|
2016-08-15 10:36:19 +01:00
|
|
|
netdev_request_reconfigure(&dev->up);
|
2016-02-26 15:58:24 -08:00
|
|
|
}
|
2016-08-15 10:36:19 +01:00
|
|
|
}
|
|
|
|
|
2016-09-30 14:50:53 +01:00
|
|
|
static void
|
|
|
|
dpdk_process_queue_size(struct netdev *netdev, const struct smap *args,
|
|
|
|
const char *flag, int default_size, int *new_size)
|
|
|
|
{
|
|
|
|
int queue_size = smap_get_int(args, flag, default_size);
|
|
|
|
|
|
|
|
if (queue_size <= 0 || queue_size > NIC_PORT_MAX_Q_SIZE
|
|
|
|
|| !is_pow2(queue_size)) {
|
|
|
|
queue_size = default_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (queue_size != *new_size) {
|
|
|
|
*new_size = queue_size;
|
|
|
|
netdev_request_reconfigure(netdev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-15 10:36:19 +01:00
|
|
|
static int
|
2016-12-20 17:58:14 -08:00
|
|
|
netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args,
|
|
|
|
char **errp)
|
2016-08-15 10:36:19 +01:00
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2018-04-23 11:42:41 +00:00
|
|
|
bool rx_fc_en, tx_fc_en, autoneg, lsc_interrupt_mode;
|
2016-09-30 10:48:45 +03:00
|
|
|
enum rte_eth_fc_mode fc_mode;
|
|
|
|
static const enum rte_eth_fc_mode fc_mode_set[2][2] = {
|
|
|
|
{RTE_FC_NONE, RTE_FC_TX_PAUSE},
|
|
|
|
{RTE_FC_RX_PAUSE, RTE_FC_FULL }
|
|
|
|
};
|
2017-01-05 10:42:09 +00:00
|
|
|
const char *new_devargs;
|
|
|
|
int err = 0;
|
2016-08-15 10:36:19 +01:00
|
|
|
|
2017-01-05 10:42:09 +00:00
|
|
|
ovs_mutex_lock(&dpdk_mutex);
|
2016-08-15 10:36:19 +01:00
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
|
|
|
|
dpdk_set_rxq_config(dev, args);
|
|
|
|
|
2016-09-30 14:50:53 +01:00
|
|
|
dpdk_process_queue_size(netdev, args, "n_rxq_desc",
|
|
|
|
NIC_PORT_DEFAULT_RXQ_SIZE,
|
|
|
|
&dev->requested_rxq_size);
|
|
|
|
dpdk_process_queue_size(netdev, args, "n_txq_desc",
|
|
|
|
NIC_PORT_DEFAULT_TXQ_SIZE,
|
|
|
|
&dev->requested_txq_size);
|
|
|
|
|
2017-01-05 10:42:09 +00:00
|
|
|
new_devargs = smap_get(args, "dpdk-devargs");
|
|
|
|
|
|
|
|
if (dev->devargs && strcmp(new_devargs, dev->devargs)) {
|
|
|
|
/* The user requested a new device. If we return error, the caller
|
|
|
|
* will delete this netdev and try to recreate it. */
|
|
|
|
err = EAGAIN;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dpdk-devargs is required for device configuration */
|
|
|
|
if (new_devargs && new_devargs[0]) {
|
|
|
|
/* Don't process dpdk-devargs if value is unchanged and port id
|
|
|
|
* is valid */
|
|
|
|
if (!(dev->devargs && !strcmp(dev->devargs, new_devargs)
|
|
|
|
&& rte_eth_dev_is_valid_port(dev->port_id))) {
|
2017-05-19 16:37:32 +03:00
|
|
|
dpdk_port_t new_port_id = netdev_dpdk_process_devargs(dev,
|
|
|
|
new_devargs,
|
|
|
|
errp);
|
2017-01-05 10:42:09 +00:00
|
|
|
if (!rte_eth_dev_is_valid_port(new_port_id)) {
|
|
|
|
err = EINVAL;
|
|
|
|
} else if (new_port_id == dev->port_id) {
|
|
|
|
/* Already configured, do not reconfigure again */
|
|
|
|
err = 0;
|
|
|
|
} else {
|
|
|
|
struct netdev_dpdk *dup_dev;
|
2017-05-19 16:37:32 +03:00
|
|
|
|
2017-01-05 10:42:09 +00:00
|
|
|
dup_dev = netdev_dpdk_lookup_by_port_id(new_port_id);
|
|
|
|
if (dup_dev) {
|
2016-12-20 17:58:14 -08:00
|
|
|
VLOG_WARN_BUF(errp, "'%s' is trying to use device '%s' "
|
|
|
|
"which is already in use by '%s'",
|
|
|
|
netdev_get_name(netdev), new_devargs,
|
|
|
|
netdev_get_name(&dup_dev->up));
|
2017-01-05 10:42:09 +00:00
|
|
|
err = EADDRINUSE;
|
|
|
|
} else {
|
2017-01-12 22:18:13 +08:00
|
|
|
int sid = rte_eth_dev_socket_id(new_port_id);
|
2017-05-19 16:37:32 +03:00
|
|
|
|
2017-01-12 22:18:13 +08:00
|
|
|
dev->requested_socket_id = sid < 0 ? SOCKET0 : sid;
|
2017-01-05 10:42:09 +00:00
|
|
|
dev->devargs = xstrdup(new_devargs);
|
|
|
|
dev->port_id = new_port_id;
|
|
|
|
netdev_request_reconfigure(&dev->up);
|
2018-01-09 07:55:37 +00:00
|
|
|
netdev_dpdk_clear_xstats(dev);
|
2017-01-05 10:42:09 +00:00
|
|
|
err = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2016-12-20 17:58:14 -08:00
|
|
|
VLOG_WARN_BUF(errp, "'%s' is missing 'options:dpdk-devargs'. "
|
|
|
|
"The old 'dpdk<port_id>' names are not supported",
|
|
|
|
netdev_get_name(netdev));
|
2017-01-05 10:42:09 +00:00
|
|
|
err = EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2018-04-23 11:42:41 +00:00
|
|
|
lsc_interrupt_mode = smap_get_bool(args, "dpdk-lsc-interrupt", false);
|
|
|
|
if (dev->requested_lsc_interrupt_mode != lsc_interrupt_mode) {
|
|
|
|
dev->requested_lsc_interrupt_mode = lsc_interrupt_mode;
|
|
|
|
netdev_request_reconfigure(netdev);
|
|
|
|
}
|
|
|
|
|
2016-08-15 10:36:19 +01:00
|
|
|
rx_fc_en = smap_get_bool(args, "rx-flow-ctrl", false);
|
|
|
|
tx_fc_en = smap_get_bool(args, "tx-flow-ctrl", false);
|
2016-09-30 10:48:45 +03:00
|
|
|
autoneg = smap_get_bool(args, "flow-ctrl-autoneg", false);
|
2016-08-15 10:36:19 +01:00
|
|
|
|
2016-09-30 10:48:45 +03:00
|
|
|
fc_mode = fc_mode_set[tx_fc_en][rx_fc_en];
|
|
|
|
if (dev->fc_conf.mode != fc_mode || autoneg != dev->fc_conf.autoneg) {
|
|
|
|
dev->fc_conf.mode = fc_mode;
|
|
|
|
dev->fc_conf.autoneg = autoneg;
|
|
|
|
dpdk_eth_flow_ctrl_setup(dev);
|
|
|
|
}
|
2016-07-28 16:30:12 +01:00
|
|
|
|
2017-01-05 10:42:09 +00:00
|
|
|
out:
|
2016-08-15 10:36:19 +01:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
2017-01-05 10:42:09 +00:00
|
|
|
ovs_mutex_unlock(&dpdk_mutex);
|
2016-08-15 10:36:19 +01:00
|
|
|
|
2017-01-05 10:42:09 +00:00
|
|
|
return err;
|
2016-08-15 10:36:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-12-20 17:58:14 -08:00
|
|
|
netdev_dpdk_ring_set_config(struct netdev *netdev, const struct smap *args,
|
|
|
|
char **errp OVS_UNUSED)
|
2016-08-15 10:36:19 +01:00
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
dpdk_set_rxq_config(dev, args);
|
2016-01-21 17:15:18 +03:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-08-15 16:11:26 +01:00
|
|
|
static int
|
2016-08-19 10:22:30 +01:00
|
|
|
netdev_dpdk_vhost_client_set_config(struct netdev *netdev,
|
2016-12-20 17:58:14 -08:00
|
|
|
const struct smap *args,
|
|
|
|
char **errp OVS_UNUSED)
|
2016-08-15 16:11:26 +01:00
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
|
|
|
const char *path;
|
|
|
|
|
2016-09-23 16:17:56 +03:00
|
|
|
ovs_mutex_lock(&dev->mutex);
|
2016-08-15 16:11:26 +01:00
|
|
|
if (!(dev->vhost_driver_flags & RTE_VHOST_USER_CLIENT)) {
|
|
|
|
path = smap_get(args, "vhost-server-path");
|
2016-08-19 10:22:30 +01:00
|
|
|
if (path && strcmp(path, dev->vhost_id)) {
|
|
|
|
strcpy(dev->vhost_id, path);
|
2018-01-31 10:44:54 +00:00
|
|
|
/* check zero copy configuration */
|
|
|
|
if (smap_get_bool(args, "dq-zero-copy", false)) {
|
|
|
|
dev->vhost_driver_flags |= RTE_VHOST_USER_DEQUEUE_ZERO_COPY;
|
|
|
|
} else {
|
|
|
|
dev->vhost_driver_flags &= ~RTE_VHOST_USER_DEQUEUE_ZERO_COPY;
|
|
|
|
}
|
2016-08-15 16:11:26 +01:00
|
|
|
netdev_request_reconfigure(netdev);
|
|
|
|
}
|
|
|
|
}
|
2016-09-23 16:17:56 +03:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
2016-08-15 16:11:26 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-06-11 16:33:08 -07:00
|
|
|
static int
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_get_numa_id(const struct netdev *netdev)
|
2014-06-11 16:33:08 -07:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2014-06-11 16:33:08 -07:00
|
|
|
|
2016-03-16 14:44:18 -07:00
|
|
|
return dev->socket_id;
|
2014-06-11 16:33:08 -07:00
|
|
|
}
|
|
|
|
|
2016-02-26 15:58:24 -08:00
|
|
|
/* Sets the number of tx queues for the dpdk interface. */
|
2014-09-08 14:52:54 -07:00
|
|
|
static int
|
2016-02-26 15:58:24 -08:00
|
|
|
netdev_dpdk_set_tx_multiq(struct netdev *netdev, unsigned int n_txq)
|
2014-09-08 14:52:54 -07:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2014-09-08 14:52:54 -07:00
|
|
|
|
2016-03-16 14:44:18 -07:00
|
|
|
ovs_mutex_lock(&dev->mutex);
|
2014-09-19 10:38:39 -07:00
|
|
|
|
2016-02-26 15:58:24 -08:00
|
|
|
if (dev->requested_n_txq == n_txq) {
|
|
|
|
goto out;
|
2016-01-26 16:58:14 -02:00
|
|
|
}
|
|
|
|
|
2016-02-26 15:58:24 -08:00
|
|
|
dev->requested_n_txq = n_txq;
|
|
|
|
netdev_request_reconfigure(netdev);
|
2015-03-05 13:42:04 -08:00
|
|
|
|
2016-02-26 15:58:24 -08:00
|
|
|
out:
|
2016-03-16 14:44:18 -07:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
2016-02-26 15:58:24 -08:00
|
|
|
return 0;
|
2015-03-05 13:42:04 -08:00
|
|
|
}
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
static struct netdev_rxq *
|
|
|
|
netdev_dpdk_rxq_alloc(void)
|
|
|
|
{
|
|
|
|
struct netdev_rxq_dpdk *rx = dpdk_rte_mzalloc(sizeof *rx);
|
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
if (rx) {
|
|
|
|
return &rx->up;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct netdev_rxq_dpdk *
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_rxq_dpdk_cast(const struct netdev_rxq *rxq)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
return CONTAINER_OF(rxq, struct netdev_rxq_dpdk, up);
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_rxq_construct(struct netdev_rxq *rxq)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_rxq_dpdk *rx = netdev_rxq_dpdk_cast(rxq);
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(rxq->netdev);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2016-03-16 14:44:18 -07:00
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
rx->port_id = dev->port_id;
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_rxq_destruct(struct netdev_rxq *rxq OVS_UNUSED)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_rxq_dealloc(struct netdev_rxq *rxq)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_rxq_dpdk *rx = netdev_rxq_dpdk_cast(rxq);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
|
|
|
rte_free(rx);
|
|
|
|
}
|
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
/* Tries to transmit 'pkts' to txq 'qid' of device 'dev'. Takes ownership of
|
|
|
|
* 'pkts', even in case of failure.
|
|
|
|
*
|
|
|
|
* Returns the number of packets that weren't transmitted. */
|
|
|
|
static inline int
|
2016-06-27 16:28:16 +03:00
|
|
|
netdev_dpdk_eth_tx_burst(struct netdev_dpdk *dev, int qid,
|
2016-10-04 17:58:05 -07:00
|
|
|
struct rte_mbuf **pkts, int cnt)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
2014-08-12 10:43:36 -07:00
|
|
|
uint32_t nb_tx = 0;
|
|
|
|
|
2016-06-27 16:28:16 +03:00
|
|
|
while (nb_tx != cnt) {
|
2014-08-12 10:43:36 -07:00
|
|
|
uint32_t ret;
|
|
|
|
|
2016-06-27 16:28:16 +03:00
|
|
|
ret = rte_eth_tx_burst(dev->port_id, qid, pkts + nb_tx, cnt - nb_tx);
|
2014-08-12 10:43:36 -07:00
|
|
|
if (!ret) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
nb_tx += ret;
|
|
|
|
}
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2016-06-27 16:28:16 +03:00
|
|
|
if (OVS_UNLIKELY(nb_tx != cnt)) {
|
2016-10-04 17:58:05 -07:00
|
|
|
/* Free buffers, which we couldn't transmit, one at a time (each
|
netdev-dpdk: Fix race condition with DPDK mempools in non pmd threads
DPDK mempools rely on rte_lcore_id() to implement a thread-local cache.
Our non pmd threads had rte_lcore_id() == 0. This allowed concurrent access to
the "thread-local" cache, causing crashes.
This commit resolves the issue with the following changes:
- Every non pmd thread has the same lcore_id (0, for management reasons), which
is not shared with any pmd thread (lcore_id for pmd threads now start from 1)
- DPDK mbufs must be allocated/freed in pmd threads. When there is the need to
use mempools in non pmd threads, like in dpdk_do_tx_copy(), a mutex must be
held.
- The previous change does not allow us anymore to pass DPDK mbufs to handler
threads: therefore this commit partially revert 143859ec63d45e. Now packets
are copied for upcall processing. We can remove the extra memcpy by
processing upcalls in the pmd thread itself.
With the introduction of the extra locking, the packet throughput will be lower
in the following cases:
- When using internal (tap) devices with DPDK devices on the same datapath.
Anyway, to support internal devices efficiently, we needed DPDK KNI devices,
which will be proper pmd devices and will not need this locking.
- When packets are processed in the slow path by non pmd threads. This overhead
can be avoided by handling the upcalls directly in pmd threads (a change that
has already been proposed by Ryan Wilson)
Also, the following two fixes have been introduced:
- In dpdk_free_buf() use rte_pktmbuf_free_seg() instead of rte_mempool_put().
This allows OVS to run properly with CONFIG_RTE_LIBRTE_MBUF_DEBUG DPDK option
- Do not bulk free mbufs in a transmission queue. They may belong to different
mempools
Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
2014-07-17 14:29:36 -07:00
|
|
|
* packet could come from a different mempool) */
|
|
|
|
int i;
|
|
|
|
|
2016-06-27 16:28:16 +03:00
|
|
|
for (i = nb_tx; i < cnt; i++) {
|
|
|
|
rte_pktmbuf_free(pkts[i]);
|
netdev-dpdk: Fix race condition with DPDK mempools in non pmd threads
DPDK mempools rely on rte_lcore_id() to implement a thread-local cache.
Our non pmd threads had rte_lcore_id() == 0. This allowed concurrent access to
the "thread-local" cache, causing crashes.
This commit resolves the issue with the following changes:
- Every non pmd thread has the same lcore_id (0, for management reasons), which
is not shared with any pmd thread (lcore_id for pmd threads now start from 1)
- DPDK mbufs must be allocated/freed in pmd threads. When there is the need to
use mempools in non pmd threads, like in dpdk_do_tx_copy(), a mutex must be
held.
- The previous change does not allow us anymore to pass DPDK mbufs to handler
threads: therefore this commit partially revert 143859ec63d45e. Now packets
are copied for upcall processing. We can remove the extra memcpy by
processing upcalls in the pmd thread itself.
With the introduction of the extra locking, the packet throughput will be lower
in the following cases:
- When using internal (tap) devices with DPDK devices on the same datapath.
Anyway, to support internal devices efficiently, we needed DPDK KNI devices,
which will be proper pmd devices and will not need this locking.
- When packets are processed in the slow path by non pmd threads. This overhead
can be avoided by handling the upcalls directly in pmd threads (a change that
has already been proposed by Ryan Wilson)
Also, the following two fixes have been introduced:
- In dpdk_free_buf() use rte_pktmbuf_free_seg() instead of rte_mempool_put().
This allows OVS to run properly with CONFIG_RTE_LIBRTE_MBUF_DEBUG DPDK option
- Do not bulk free mbufs in a transmission queue. They may belong to different
mempools
Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
2014-07-17 14:29:36 -07:00
|
|
|
}
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
2016-10-04 17:58:05 -07:00
|
|
|
|
|
|
|
return cnt - nb_tx;
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
|
2016-05-24 17:36:50 +01:00
|
|
|
static inline bool
|
|
|
|
netdev_dpdk_policer_pkt_handle(struct rte_meter_srtcm *meter,
|
|
|
|
struct rte_mbuf *pkt, uint64_t time)
|
|
|
|
{
|
|
|
|
uint32_t pkt_len = rte_pktmbuf_pkt_len(pkt) - sizeof(struct ether_hdr);
|
|
|
|
|
|
|
|
return rte_meter_srtcm_color_blind_check(meter, time, pkt_len) ==
|
|
|
|
e_RTE_METER_GREEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netdev_dpdk_policer_run(struct rte_meter_srtcm *meter,
|
2017-09-06 22:21:59 -07:00
|
|
|
struct rte_mbuf **pkts, int pkt_cnt,
|
2018-05-16 19:24:46 -07:00
|
|
|
bool should_steal)
|
2016-05-24 17:36:50 +01:00
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
int cnt = 0;
|
|
|
|
struct rte_mbuf *pkt = NULL;
|
|
|
|
uint64_t current_time = rte_rdtsc();
|
|
|
|
|
|
|
|
for (i = 0; i < pkt_cnt; i++) {
|
|
|
|
pkt = pkts[i];
|
|
|
|
/* Handle current packet */
|
|
|
|
if (netdev_dpdk_policer_pkt_handle(meter, pkt, current_time)) {
|
|
|
|
if (cnt != i) {
|
|
|
|
pkts[cnt] = pkt;
|
|
|
|
}
|
|
|
|
cnt++;
|
|
|
|
} else {
|
2018-05-16 19:24:46 -07:00
|
|
|
if (should_steal) {
|
2017-09-06 22:21:59 -07:00
|
|
|
rte_pktmbuf_free(pkt);
|
|
|
|
}
|
2016-05-24 17:36:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
2016-05-24 17:36:51 +01:00
|
|
|
static int
|
|
|
|
ingress_policer_run(struct ingress_policer *policer, struct rte_mbuf **pkts,
|
2018-05-16 19:24:46 -07:00
|
|
|
int pkt_cnt, bool should_steal)
|
2016-05-24 17:36:51 +01:00
|
|
|
{
|
|
|
|
int cnt = 0;
|
|
|
|
|
|
|
|
rte_spinlock_lock(&policer->policer_lock);
|
2017-09-06 22:21:59 -07:00
|
|
|
cnt = netdev_dpdk_policer_run(&policer->in_policer, pkts,
|
2018-05-16 19:24:46 -07:00
|
|
|
pkt_cnt, should_steal);
|
2016-05-24 17:36:51 +01:00
|
|
|
rte_spinlock_unlock(&policer->policer_lock);
|
|
|
|
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
static bool
|
2016-08-03 13:29:24 +01:00
|
|
|
is_vhost_running(struct netdev_dpdk *dev)
|
2015-03-05 13:42:04 -08:00
|
|
|
{
|
2016-08-03 13:29:24 +01:00
|
|
|
return (netdev_dpdk_get_vid(dev) >= 0 && dev->vhost_reconfigured);
|
2015-03-05 13:42:04 -08:00
|
|
|
}
|
|
|
|
|
2016-05-05 09:46:01 +01:00
|
|
|
static inline void
|
|
|
|
netdev_dpdk_vhost_update_rx_size_counters(struct netdev_stats *stats,
|
|
|
|
unsigned int packet_size)
|
|
|
|
{
|
|
|
|
/* Hard-coded search for the size bucket. */
|
|
|
|
if (packet_size < 256) {
|
|
|
|
if (packet_size >= 128) {
|
|
|
|
stats->rx_128_to_255_packets++;
|
|
|
|
} else if (packet_size <= 64) {
|
|
|
|
stats->rx_1_to_64_packets++;
|
|
|
|
} else {
|
|
|
|
stats->rx_65_to_127_packets++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (packet_size >= 1523) {
|
|
|
|
stats->rx_1523_to_max_packets++;
|
|
|
|
} else if (packet_size >= 1024) {
|
|
|
|
stats->rx_1024_to_1522_packets++;
|
|
|
|
} else if (packet_size < 512) {
|
|
|
|
stats->rx_256_to_511_packets++;
|
|
|
|
} else {
|
|
|
|
stats->rx_512_to_1023_packets++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-01 11:49:12 +01:00
|
|
|
static inline void
|
|
|
|
netdev_dpdk_vhost_update_rx_counters(struct netdev_stats *stats,
|
2016-05-24 17:36:51 +01:00
|
|
|
struct dp_packet **packets, int count,
|
|
|
|
int dropped)
|
2015-07-01 11:49:12 +01:00
|
|
|
{
|
|
|
|
int i;
|
2016-05-05 09:46:01 +01:00
|
|
|
unsigned int packet_size;
|
2015-07-01 11:49:12 +01:00
|
|
|
struct dp_packet *packet;
|
|
|
|
|
|
|
|
stats->rx_packets += count;
|
2016-05-24 17:36:51 +01:00
|
|
|
stats->rx_dropped += dropped;
|
2015-07-01 11:49:12 +01:00
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
packet = packets[i];
|
2016-05-05 09:46:01 +01:00
|
|
|
packet_size = dp_packet_size(packet);
|
2015-07-01 11:49:12 +01:00
|
|
|
|
2016-05-05 09:46:01 +01:00
|
|
|
if (OVS_UNLIKELY(packet_size < ETH_HEADER_LEN)) {
|
2015-07-01 11:49:12 +01:00
|
|
|
/* This only protects the following multicast counting from
|
|
|
|
* too short packets, but it does not stop the packet from
|
|
|
|
* further processing. */
|
|
|
|
stats->rx_errors++;
|
|
|
|
stats->rx_length_errors++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-05-05 09:46:01 +01:00
|
|
|
netdev_dpdk_vhost_update_rx_size_counters(stats, packet_size);
|
|
|
|
|
2015-07-01 11:49:12 +01:00
|
|
|
struct eth_header *eh = (struct eth_header *) dp_packet_data(packet);
|
|
|
|
if (OVS_UNLIKELY(eth_addr_is_multicast(eh->eth_dst))) {
|
|
|
|
stats->multicast++;
|
|
|
|
}
|
|
|
|
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->rx_bytes += packet_size;
|
2015-07-01 11:49:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
/*
|
|
|
|
* The receive path for the vhost port is the TX path out from guest.
|
|
|
|
*/
|
|
|
|
static int
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
|
2018-04-19 19:40:44 +02:00
|
|
|
struct dp_packet_batch *batch, int *qfill)
|
2015-03-05 13:42:04 -08:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(rxq->netdev);
|
2016-05-24 17:36:51 +01:00
|
|
|
struct ingress_policer *policer = netdev_dpdk_get_ingress_policer(dev);
|
2015-03-05 13:42:04 -08:00
|
|
|
uint16_t nb_rx = 0;
|
2016-05-24 17:36:51 +01:00
|
|
|
uint16_t dropped = 0;
|
2018-04-19 19:40:44 +02:00
|
|
|
int qid = rxq->queue_id * VIRTIO_QNUM + VIRTIO_TXQ;
|
2017-10-06 13:50:14 +03:00
|
|
|
int vid = netdev_dpdk_get_vid(dev);
|
2015-03-05 13:42:04 -08:00
|
|
|
|
2017-10-06 13:50:14 +03:00
|
|
|
if (OVS_UNLIKELY(vid < 0 || !dev->vhost_reconfigured
|
2016-06-02 12:42:39 +00:00
|
|
|
|| !(dev->flags & NETDEV_UP))) {
|
2015-03-05 13:42:04 -08:00
|
|
|
return EAGAIN;
|
|
|
|
}
|
|
|
|
|
2018-04-19 19:40:44 +02:00
|
|
|
nb_rx = rte_vhost_dequeue_burst(vid, qid, dev->mp,
|
2016-07-18 17:05:35 -07:00
|
|
|
(struct rte_mbuf **) batch->packets,
|
2015-05-16 08:18:20 -07:00
|
|
|
NETDEV_MAX_BURST);
|
2015-03-05 13:42:04 -08:00
|
|
|
if (!nb_rx) {
|
|
|
|
return EAGAIN;
|
|
|
|
}
|
|
|
|
|
2018-04-19 19:40:44 +02:00
|
|
|
if (qfill) {
|
|
|
|
if (nb_rx == NETDEV_MAX_BURST) {
|
|
|
|
/* The DPDK API returns a uint32_t which often has invalid bits in
|
|
|
|
* the upper 16-bits. Need to restrict the value to uint16_t. */
|
|
|
|
*qfill = rte_vhost_rx_queue_count(vid, qid) & UINT16_MAX;
|
|
|
|
} else {
|
|
|
|
*qfill = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-24 17:36:51 +01:00
|
|
|
if (policer) {
|
|
|
|
dropped = nb_rx;
|
2016-07-18 17:05:35 -07:00
|
|
|
nb_rx = ingress_policer_run(policer,
|
|
|
|
(struct rte_mbuf **) batch->packets,
|
2017-09-06 22:21:59 -07:00
|
|
|
nb_rx, true);
|
2016-05-24 17:36:51 +01:00
|
|
|
dropped -= nb_rx;
|
|
|
|
}
|
|
|
|
|
2016-03-16 14:44:18 -07:00
|
|
|
rte_spinlock_lock(&dev->stats_lock);
|
2016-07-18 17:05:35 -07:00
|
|
|
netdev_dpdk_vhost_update_rx_counters(&dev->stats, batch->packets,
|
|
|
|
nb_rx, dropped);
|
2016-03-16 14:44:18 -07:00
|
|
|
rte_spinlock_unlock(&dev->stats_lock);
|
2015-05-22 17:14:21 +01:00
|
|
|
|
2017-09-22 02:58:13 -07:00
|
|
|
batch->count = nb_rx;
|
|
|
|
dp_packet_batch_init_packet_fields(batch);
|
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
static int
|
2018-04-19 19:40:44 +02:00
|
|
|
netdev_dpdk_rxq_recv(struct netdev_rxq *rxq, struct dp_packet_batch *batch,
|
|
|
|
int *qfill)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_rxq_dpdk *rx = netdev_rxq_dpdk_cast(rxq);
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(rxq->netdev);
|
2016-05-24 17:36:51 +01:00
|
|
|
struct ingress_policer *policer = netdev_dpdk_get_ingress_policer(dev);
|
2014-03-24 19:23:08 -07:00
|
|
|
int nb_rx;
|
2016-05-24 17:36:51 +01:00
|
|
|
int dropped = 0;
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2016-11-15 15:40:49 -08:00
|
|
|
if (OVS_UNLIKELY(!(dev->flags & NETDEV_UP))) {
|
|
|
|
return EAGAIN;
|
|
|
|
}
|
|
|
|
|
2016-03-16 14:44:18 -07:00
|
|
|
nb_rx = rte_eth_rx_burst(rx->port_id, rxq->queue_id,
|
2016-07-18 17:05:35 -07:00
|
|
|
(struct rte_mbuf **) batch->packets,
|
2015-05-16 08:18:20 -07:00
|
|
|
NETDEV_MAX_BURST);
|
2014-03-24 19:23:08 -07:00
|
|
|
if (!nb_rx) {
|
|
|
|
return EAGAIN;
|
|
|
|
}
|
|
|
|
|
2016-05-24 17:36:51 +01:00
|
|
|
if (policer) {
|
|
|
|
dropped = nb_rx;
|
2016-07-18 17:05:35 -07:00
|
|
|
nb_rx = ingress_policer_run(policer,
|
2016-09-29 11:27:03 +01:00
|
|
|
(struct rte_mbuf **) batch->packets,
|
2017-09-06 22:21:59 -07:00
|
|
|
nb_rx, true);
|
2016-05-24 17:36:51 +01:00
|
|
|
dropped -= nb_rx;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update stats to reflect dropped packets */
|
|
|
|
if (OVS_UNLIKELY(dropped)) {
|
|
|
|
rte_spinlock_lock(&dev->stats_lock);
|
|
|
|
dev->stats.rx_dropped += dropped;
|
|
|
|
rte_spinlock_unlock(&dev->stats_lock);
|
|
|
|
}
|
|
|
|
|
2016-07-18 17:05:35 -07:00
|
|
|
batch->count = nb_rx;
|
2017-09-22 02:58:13 -07:00
|
|
|
dp_packet_batch_init_packet_fields(batch);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2018-04-19 19:40:44 +02:00
|
|
|
if (qfill) {
|
|
|
|
if (nb_rx == NETDEV_MAX_BURST) {
|
|
|
|
*qfill = rte_eth_rx_queue_count(rx->port_id, rxq->queue_id);
|
|
|
|
} else {
|
|
|
|
*qfill = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-03-02 20:35:54 +00:00
|
|
|
static inline int
|
2016-10-04 17:58:05 -07:00
|
|
|
netdev_dpdk_qos_run(struct netdev_dpdk *dev, struct rte_mbuf **pkts,
|
2018-05-16 19:24:46 -07:00
|
|
|
int cnt, bool should_steal)
|
2016-03-02 20:35:54 +00:00
|
|
|
{
|
2016-10-04 17:58:05 -07:00
|
|
|
struct qos_conf *qos_conf = ovsrcu_get(struct qos_conf *, &dev->qos_conf);
|
2016-03-02 20:35:54 +00:00
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
if (qos_conf) {
|
|
|
|
rte_spinlock_lock(&qos_conf->lock);
|
2018-05-16 19:24:46 -07:00
|
|
|
cnt = qos_conf->ops->qos_run(qos_conf, pkts, cnt, should_steal);
|
2016-10-04 17:58:05 -07:00
|
|
|
rte_spinlock_unlock(&qos_conf->lock);
|
2016-03-02 20:35:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
2016-08-18 16:13:58 +03:00
|
|
|
static int
|
|
|
|
netdev_dpdk_filter_packet_len(struct netdev_dpdk *dev, struct rte_mbuf **pkts,
|
|
|
|
int pkt_cnt)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
int cnt = 0;
|
|
|
|
struct rte_mbuf *pkt;
|
|
|
|
|
|
|
|
for (i = 0; i < pkt_cnt; i++) {
|
|
|
|
pkt = pkts[i];
|
|
|
|
if (OVS_UNLIKELY(pkt->pkt_len > dev->max_packet_len)) {
|
|
|
|
VLOG_WARN_RL(&rl, "%s: Too big size %" PRIu32 " max_packet_len %d",
|
|
|
|
dev->up.name, pkt->pkt_len, dev->max_packet_len);
|
|
|
|
rte_pktmbuf_free(pkt);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OVS_UNLIKELY(i != cnt)) {
|
|
|
|
pkts[cnt] = pkt;
|
|
|
|
}
|
|
|
|
cnt++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
2015-07-01 11:49:12 +01:00
|
|
|
static inline void
|
|
|
|
netdev_dpdk_vhost_update_tx_counters(struct netdev_stats *stats,
|
|
|
|
struct dp_packet **packets,
|
|
|
|
int attempted,
|
|
|
|
int dropped)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int sent = attempted - dropped;
|
|
|
|
|
|
|
|
stats->tx_packets += sent;
|
|
|
|
stats->tx_dropped += dropped;
|
|
|
|
|
|
|
|
for (i = 0; i < sent; i++) {
|
|
|
|
stats->tx_bytes += dp_packet_size(packets[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
static void
|
2016-01-26 16:58:14 -02:00
|
|
|
__netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
|
2016-08-10 12:43:03 +03:00
|
|
|
struct dp_packet **pkts, int cnt)
|
2015-03-05 13:42:04 -08:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2015-05-11 21:58:14 -07:00
|
|
|
struct rte_mbuf **cur_pkts = (struct rte_mbuf **) pkts;
|
|
|
|
unsigned int total_pkts = cnt;
|
2016-08-18 16:13:58 +03:00
|
|
|
unsigned int dropped = 0;
|
2016-08-10 12:43:03 +03:00
|
|
|
int i, retries = 0;
|
2017-10-06 13:50:14 +03:00
|
|
|
int vid = netdev_dpdk_get_vid(dev);
|
2015-03-05 13:42:04 -08:00
|
|
|
|
2016-07-08 16:52:37 +03:00
|
|
|
qid = dev->tx_q[qid % netdev->n_txq].map;
|
2016-02-24 17:14:43 +03:00
|
|
|
|
2017-10-06 13:50:14 +03:00
|
|
|
if (OVS_UNLIKELY(vid < 0 || !dev->vhost_reconfigured || qid < 0
|
2016-06-02 12:42:39 +00:00
|
|
|
|| !(dev->flags & NETDEV_UP))) {
|
2016-03-16 14:44:18 -07:00
|
|
|
rte_spinlock_lock(&dev->stats_lock);
|
|
|
|
dev->stats.tx_dropped+= cnt;
|
|
|
|
rte_spinlock_unlock(&dev->stats_lock);
|
2015-04-13 06:36:56 -07:00
|
|
|
goto out;
|
2015-03-05 13:42:04 -08:00
|
|
|
}
|
|
|
|
|
2016-03-16 14:44:18 -07:00
|
|
|
rte_spinlock_lock(&dev->tx_q[qid].tx_lock);
|
2015-03-05 13:42:04 -08:00
|
|
|
|
2016-08-18 16:13:58 +03:00
|
|
|
cnt = netdev_dpdk_filter_packet_len(dev, cur_pkts, cnt);
|
2016-03-02 20:35:54 +00:00
|
|
|
/* Check has QoS has been configured for the netdev */
|
2017-09-06 22:21:59 -07:00
|
|
|
cnt = netdev_dpdk_qos_run(dev, cur_pkts, cnt, true);
|
2016-08-18 16:13:58 +03:00
|
|
|
dropped = total_pkts - cnt;
|
2016-03-02 20:35:54 +00:00
|
|
|
|
2015-05-11 21:58:14 -07:00
|
|
|
do {
|
2016-01-26 16:58:14 -02:00
|
|
|
int vhost_qid = qid * VIRTIO_QNUM + VIRTIO_RXQ;
|
2015-05-11 21:58:14 -07:00
|
|
|
unsigned int tx_pkts;
|
|
|
|
|
2017-10-06 13:50:14 +03:00
|
|
|
tx_pkts = rte_vhost_enqueue_burst(vid, vhost_qid, cur_pkts, cnt);
|
2015-05-11 21:58:14 -07:00
|
|
|
if (OVS_LIKELY(tx_pkts)) {
|
|
|
|
/* Packets have been sent.*/
|
|
|
|
cnt -= tx_pkts;
|
2016-06-10 17:49:38 +01:00
|
|
|
/* Prepare for possible retry.*/
|
2015-05-11 21:58:14 -07:00
|
|
|
cur_pkts = &cur_pkts[tx_pkts];
|
|
|
|
} else {
|
2016-06-10 17:49:38 +01:00
|
|
|
/* No packets sent - do not retry.*/
|
|
|
|
break;
|
2015-05-11 21:58:14 -07:00
|
|
|
}
|
2016-08-18 16:13:58 +03:00
|
|
|
} while (cnt && (retries++ <= VHOST_ENQ_RETRY_NUM));
|
2016-01-26 16:58:14 -02:00
|
|
|
|
2016-03-16 14:44:18 -07:00
|
|
|
rte_spinlock_unlock(&dev->tx_q[qid].tx_lock);
|
2015-05-11 21:58:14 -07:00
|
|
|
|
2016-03-16 14:44:18 -07:00
|
|
|
rte_spinlock_lock(&dev->stats_lock);
|
2016-08-09 17:01:20 +01:00
|
|
|
netdev_dpdk_vhost_update_tx_counters(&dev->stats, pkts, total_pkts,
|
2016-08-18 16:13:58 +03:00
|
|
|
cnt + dropped);
|
2016-03-16 14:44:18 -07:00
|
|
|
rte_spinlock_unlock(&dev->stats_lock);
|
2015-03-05 13:42:04 -08:00
|
|
|
|
|
|
|
out:
|
2016-08-18 16:13:58 +03:00
|
|
|
for (i = 0; i < total_pkts - dropped; i++) {
|
2016-08-10 12:43:03 +03:00
|
|
|
dp_packet_delete(pkts[i]);
|
2015-03-05 13:42:04 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
/* Tx function. Transmit packets indefinitely */
|
|
|
|
static void
|
2016-07-18 17:05:35 -07:00
|
|
|
dpdk_do_tx_copy(struct netdev *netdev, int qid, struct dp_packet_batch *batch)
|
netdev-dpdk: Fix race condition with DPDK mempools in non pmd threads
DPDK mempools rely on rte_lcore_id() to implement a thread-local cache.
Our non pmd threads had rte_lcore_id() == 0. This allowed concurrent access to
the "thread-local" cache, causing crashes.
This commit resolves the issue with the following changes:
- Every non pmd thread has the same lcore_id (0, for management reasons), which
is not shared with any pmd thread (lcore_id for pmd threads now start from 1)
- DPDK mbufs must be allocated/freed in pmd threads. When there is the need to
use mempools in non pmd threads, like in dpdk_do_tx_copy(), a mutex must be
held.
- The previous change does not allow us anymore to pass DPDK mbufs to handler
threads: therefore this commit partially revert 143859ec63d45e. Now packets
are copied for upcall processing. We can remove the extra memcpy by
processing upcalls in the pmd thread itself.
With the introduction of the extra locking, the packet throughput will be lower
in the following cases:
- When using internal (tap) devices with DPDK devices on the same datapath.
Anyway, to support internal devices efficiently, we needed DPDK KNI devices,
which will be proper pmd devices and will not need this locking.
- When packets are processed in the slow path by non pmd threads. This overhead
can be avoided by handling the upcalls directly in pmd threads (a change that
has already been proposed by Ryan Wilson)
Also, the following two fixes have been introduced:
- In dpdk_free_buf() use rte_pktmbuf_free_seg() instead of rte_mempool_put().
This allows OVS to run properly with CONFIG_RTE_LIBRTE_MBUF_DEBUG DPDK option
- Do not bulk free mbufs in a transmission queue. They may belong to different
mempools
Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
2014-07-17 14:29:36 -07:00
|
|
|
OVS_NO_THREAD_SAFETY_ANALYSIS
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
2017-09-22 02:12:22 -07:00
|
|
|
const size_t batch_cnt = dp_packet_batch_size(batch);
|
2015-05-18 08:49:24 -07:00
|
|
|
#if !defined(__CHECKER__) && !defined(_WIN32)
|
2017-09-22 02:12:22 -07:00
|
|
|
const size_t PKT_ARRAY_SIZE = batch_cnt;
|
2015-05-18 08:49:24 -07:00
|
|
|
#else
|
|
|
|
/* Sparse or MSVC doesn't like variable length array. */
|
2015-05-16 08:18:20 -07:00
|
|
|
enum { PKT_ARRAY_SIZE = NETDEV_MAX_BURST };
|
2015-05-18 08:49:24 -07:00
|
|
|
#endif
|
2014-03-24 19:23:08 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2016-09-29 11:27:02 +01:00
|
|
|
struct rte_mbuf *pkts[PKT_ARRAY_SIZE];
|
2017-09-22 02:12:22 -07:00
|
|
|
uint32_t cnt = batch_cnt;
|
2017-09-06 22:21:59 -07:00
|
|
|
uint32_t dropped = 0;
|
|
|
|
|
|
|
|
if (dev->type != DPDK_DEV_VHOST) {
|
|
|
|
/* Check if QoS has been configured for this netdev. */
|
|
|
|
cnt = netdev_dpdk_qos_run(dev, (struct rte_mbuf **) batch->packets,
|
2017-09-22 02:12:22 -07:00
|
|
|
batch_cnt, false);
|
|
|
|
dropped += batch_cnt - cnt;
|
2017-09-06 22:21:59 -07:00
|
|
|
}
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2017-09-06 22:21:59 -07:00
|
|
|
uint32_t txcnt = 0;
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < cnt; i++) {
|
2017-09-22 02:12:22 -07:00
|
|
|
struct dp_packet *packet = batch->packets[i];
|
|
|
|
uint32_t size = dp_packet_size(packet);
|
2014-07-11 13:37:11 +01:00
|
|
|
|
2014-06-26 18:16:41 -07:00
|
|
|
if (OVS_UNLIKELY(size > dev->max_packet_len)) {
|
2017-09-06 22:21:59 -07:00
|
|
|
VLOG_WARN_RL(&rl, "Too big size %u max_packet_len %d",
|
|
|
|
size, dev->max_packet_len);
|
2014-06-23 11:43:58 -07:00
|
|
|
|
2014-06-26 18:16:39 -07:00
|
|
|
dropped++;
|
2014-06-23 11:43:58 -07:00
|
|
|
continue;
|
|
|
|
}
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2017-11-10 18:16:11 +03:00
|
|
|
pkts[txcnt] = rte_pktmbuf_alloc(dev->mp);
|
2017-09-22 02:12:22 -07:00
|
|
|
if (OVS_UNLIKELY(!pkts[txcnt])) {
|
2017-09-06 22:21:59 -07:00
|
|
|
dropped += cnt - i;
|
2014-06-26 18:16:39 -07:00
|
|
|
break;
|
2014-06-23 11:43:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* We have to do a copy for now */
|
2017-09-06 22:21:59 -07:00
|
|
|
memcpy(rte_pktmbuf_mtod(pkts[txcnt], void *),
|
2017-09-22 02:12:22 -07:00
|
|
|
dp_packet_data(packet), size);
|
|
|
|
dp_packet_set_size((struct dp_packet *)pkts[txcnt], size);
|
2014-06-23 11:43:58 -07:00
|
|
|
|
2017-09-06 22:21:59 -07:00
|
|
|
txcnt++;
|
2014-06-23 11:43:58 -07:00
|
|
|
}
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2017-09-06 22:21:59 -07:00
|
|
|
if (OVS_LIKELY(txcnt)) {
|
|
|
|
if (dev->type == DPDK_DEV_VHOST) {
|
|
|
|
__netdev_dpdk_vhost_send(netdev, qid, (struct dp_packet **) pkts,
|
|
|
|
txcnt);
|
|
|
|
} else {
|
|
|
|
dropped += netdev_dpdk_eth_tx_burst(dev, qid, pkts, txcnt);
|
|
|
|
}
|
2015-03-05 13:42:04 -08:00
|
|
|
}
|
netdev-dpdk: Fix race condition with DPDK mempools in non pmd threads
DPDK mempools rely on rte_lcore_id() to implement a thread-local cache.
Our non pmd threads had rte_lcore_id() == 0. This allowed concurrent access to
the "thread-local" cache, causing crashes.
This commit resolves the issue with the following changes:
- Every non pmd thread has the same lcore_id (0, for management reasons), which
is not shared with any pmd thread (lcore_id for pmd threads now start from 1)
- DPDK mbufs must be allocated/freed in pmd threads. When there is the need to
use mempools in non pmd threads, like in dpdk_do_tx_copy(), a mutex must be
held.
- The previous change does not allow us anymore to pass DPDK mbufs to handler
threads: therefore this commit partially revert 143859ec63d45e. Now packets
are copied for upcall processing. We can remove the extra memcpy by
processing upcalls in the pmd thread itself.
With the introduction of the extra locking, the packet throughput will be lower
in the following cases:
- When using internal (tap) devices with DPDK devices on the same datapath.
Anyway, to support internal devices efficiently, we needed DPDK KNI devices,
which will be proper pmd devices and will not need this locking.
- When packets are processed in the slow path by non pmd threads. This overhead
can be avoided by handling the upcalls directly in pmd threads (a change that
has already been proposed by Ryan Wilson)
Also, the following two fixes have been introduced:
- In dpdk_free_buf() use rte_pktmbuf_free_seg() instead of rte_mempool_put().
This allows OVS to run properly with CONFIG_RTE_LIBRTE_MBUF_DEBUG DPDK option
- Do not bulk free mbufs in a transmission queue. They may belong to different
mempools
Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
2014-07-17 14:29:36 -07:00
|
|
|
|
2016-03-02 20:35:54 +00:00
|
|
|
if (OVS_UNLIKELY(dropped)) {
|
|
|
|
rte_spinlock_lock(&dev->stats_lock);
|
|
|
|
dev->stats.tx_dropped += dropped;
|
|
|
|
rte_spinlock_unlock(&dev->stats_lock);
|
|
|
|
}
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
static int
|
2016-07-18 17:05:35 -07:00
|
|
|
netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
|
|
|
|
struct dp_packet_batch *batch,
|
2017-12-14 14:59:25 +03:00
|
|
|
bool concurrent_txq OVS_UNUSED)
|
2015-03-05 13:42:04 -08:00
|
|
|
{
|
|
|
|
|
2017-12-14 14:59:25 +03:00
|
|
|
if (OVS_UNLIKELY(batch->packets[0]->source != DPBUF_DPDK)) {
|
2016-07-18 17:05:35 -07:00
|
|
|
dpdk_do_tx_copy(netdev, qid, batch);
|
2017-12-14 14:59:25 +03:00
|
|
|
dp_packet_delete_batch(batch, true);
|
2015-03-05 13:42:04 -08:00
|
|
|
} else {
|
2016-08-10 12:43:03 +03:00
|
|
|
__netdev_dpdk_vhost_send(netdev, qid, batch->packets, batch->count);
|
2015-03-05 13:42:04 -08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-10-14 19:01:49 +02:00
|
|
|
static inline void
|
|
|
|
netdev_dpdk_send__(struct netdev_dpdk *dev, int qid,
|
2017-12-14 14:59:25 +03:00
|
|
|
struct dp_packet_batch *batch,
|
2016-07-27 17:44:41 +03:00
|
|
|
bool concurrent_txq)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
2016-11-15 15:40:49 -08:00
|
|
|
if (OVS_UNLIKELY(!(dev->flags & NETDEV_UP))) {
|
2017-12-14 14:59:25 +03:00
|
|
|
dp_packet_delete_batch(batch, true);
|
2016-11-15 15:40:49 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-27 17:44:41 +03:00
|
|
|
if (OVS_UNLIKELY(concurrent_txq)) {
|
2016-07-08 16:52:37 +03:00
|
|
|
qid = qid % dev->up.n_txq;
|
2015-05-22 17:14:22 +01:00
|
|
|
rte_spinlock_lock(&dev->tx_q[qid].tx_lock);
|
|
|
|
}
|
|
|
|
|
2017-12-14 14:59:25 +03:00
|
|
|
if (OVS_UNLIKELY(batch->packets[0]->source != DPBUF_DPDK)) {
|
2014-10-14 19:01:49 +02:00
|
|
|
struct netdev *netdev = &dev->up;
|
|
|
|
|
2016-07-18 17:05:35 -07:00
|
|
|
dpdk_do_tx_copy(netdev, qid, batch);
|
2017-12-14 14:59:25 +03:00
|
|
|
dp_packet_delete_batch(batch, true);
|
2014-03-24 19:23:08 -07:00
|
|
|
} else {
|
2017-09-22 02:14:59 -07:00
|
|
|
int tx_cnt, dropped;
|
|
|
|
int batch_cnt = dp_packet_batch_size(batch);
|
2016-09-29 11:27:02 +01:00
|
|
|
struct rte_mbuf **pkts = (struct rte_mbuf **) batch->packets;
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2017-09-22 02:14:59 -07:00
|
|
|
tx_cnt = netdev_dpdk_filter_packet_len(dev, pkts, batch_cnt);
|
|
|
|
tx_cnt = netdev_dpdk_qos_run(dev, pkts, tx_cnt, true);
|
|
|
|
dropped = batch_cnt - tx_cnt;
|
2015-04-13 06:36:56 -07:00
|
|
|
|
2017-09-22 02:14:59 -07:00
|
|
|
dropped += netdev_dpdk_eth_tx_burst(dev, qid, pkts, tx_cnt);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2014-06-23 11:43:58 -07:00
|
|
|
if (OVS_UNLIKELY(dropped)) {
|
2015-05-22 17:14:21 +01:00
|
|
|
rte_spinlock_lock(&dev->stats_lock);
|
2014-06-23 11:43:58 -07:00
|
|
|
dev->stats.tx_dropped += dropped;
|
2015-05-22 17:14:21 +01:00
|
|
|
rte_spinlock_unlock(&dev->stats_lock);
|
2014-06-23 11:43:58 -07:00
|
|
|
}
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
2015-05-22 17:14:22 +01:00
|
|
|
|
2016-07-27 17:44:41 +03:00
|
|
|
if (OVS_UNLIKELY(concurrent_txq)) {
|
2015-05-22 17:14:22 +01:00
|
|
|
rte_spinlock_unlock(&dev->tx_q[qid].tx_lock);
|
|
|
|
}
|
2014-10-14 19:01:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netdev_dpdk_eth_send(struct netdev *netdev, int qid,
|
2017-12-14 14:59:25 +03:00
|
|
|
struct dp_packet_batch *batch, bool concurrent_txq)
|
2014-10-14 19:01:49 +02:00
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2017-12-14 14:59:25 +03:00
|
|
|
netdev_dpdk_send__(dev, qid, batch, concurrent_txq);
|
2014-10-14 19:01:49 +02:00
|
|
|
return 0;
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-08-28 14:55:11 -07:00
|
|
|
netdev_dpdk_set_etheraddr(struct netdev *netdev, const struct eth_addr mac)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
if (!eth_addr_equals(dev->hwaddr, mac)) {
|
2015-08-28 14:55:11 -07:00
|
|
|
dev->hwaddr = mac;
|
2014-04-03 09:46:31 -07:00
|
|
|
netdev_change_seq_changed(netdev);
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-08-28 14:55:11 -07:00
|
|
|
netdev_dpdk_get_etheraddr(const struct netdev *netdev, struct eth_addr *mac)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
2015-08-28 14:55:11 -07:00
|
|
|
*mac = dev->hwaddr;
|
2014-03-24 19:23:08 -07:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netdev_dpdk_get_mtu(const struct netdev *netdev, int *mtup)
|
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
*mtup = dev->mtu;
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-08-09 17:01:20 +01:00
|
|
|
static int
|
|
|
|
netdev_dpdk_set_mtu(struct netdev *netdev, int mtu)
|
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
|
|
|
|
2018-01-09 16:09:28 +00:00
|
|
|
/* XXX: Ensure that the overall frame length of the requested MTU does not
|
|
|
|
* surpass the NETDEV_DPDK_MAX_PKT_LEN. DPDK device drivers differ in how
|
|
|
|
* the L2 frame length is calculated for a given MTU when
|
|
|
|
* rte_eth_dev_set_mtu(mtu) is called e.g. i40e driver includes 2 x vlan
|
|
|
|
* headers, the em driver includes 1 x vlan header, the ixgbe driver does
|
|
|
|
* not include vlan headers. As such we should use
|
|
|
|
* MTU_TO_MAX_FRAME_LEN(mtu) which includes an additional 2 x vlan headers
|
|
|
|
* (8 bytes) for comparison. This avoids a failure later with
|
|
|
|
* rte_eth_dev_set_mtu(). This approach should be used until DPDK provides
|
|
|
|
* a method to retrieve the upper bound MTU for a given device.
|
|
|
|
*/
|
|
|
|
if (MTU_TO_MAX_FRAME_LEN(mtu) > NETDEV_DPDK_MAX_PKT_LEN
|
2016-08-09 17:01:20 +01:00
|
|
|
|| mtu < ETHER_MIN_MTU) {
|
|
|
|
VLOG_WARN("%s: unsupported MTU %d\n", dev->up.name, mtu);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
if (dev->requested_mtu != mtu) {
|
|
|
|
dev->requested_mtu = mtu;
|
|
|
|
netdev_request_reconfigure(netdev);
|
|
|
|
}
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
static int
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_get_carrier(const struct netdev *netdev, bool *carrier);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
static int
|
|
|
|
netdev_dpdk_vhost_get_stats(const struct netdev *netdev,
|
|
|
|
struct netdev_stats *stats)
|
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
|
2015-05-22 17:14:21 +01:00
|
|
|
rte_spinlock_lock(&dev->stats_lock);
|
2015-03-05 13:42:04 -08:00
|
|
|
/* Supported Stats */
|
2017-08-25 14:49:55 -07:00
|
|
|
stats->rx_packets = dev->stats.rx_packets;
|
|
|
|
stats->tx_packets = dev->stats.tx_packets;
|
2016-05-24 17:36:51 +01:00
|
|
|
stats->rx_dropped = dev->stats.rx_dropped;
|
2017-08-25 14:49:55 -07:00
|
|
|
stats->tx_dropped = dev->stats.tx_dropped;
|
2015-07-01 11:49:12 +01:00
|
|
|
stats->multicast = dev->stats.multicast;
|
|
|
|
stats->rx_bytes = dev->stats.rx_bytes;
|
|
|
|
stats->tx_bytes = dev->stats.tx_bytes;
|
|
|
|
stats->rx_errors = dev->stats.rx_errors;
|
|
|
|
stats->rx_length_errors = dev->stats.rx_length_errors;
|
2016-05-05 09:46:01 +01:00
|
|
|
|
|
|
|
stats->rx_1_to_64_packets = dev->stats.rx_1_to_64_packets;
|
|
|
|
stats->rx_65_to_127_packets = dev->stats.rx_65_to_127_packets;
|
|
|
|
stats->rx_128_to_255_packets = dev->stats.rx_128_to_255_packets;
|
|
|
|
stats->rx_256_to_511_packets = dev->stats.rx_256_to_511_packets;
|
|
|
|
stats->rx_512_to_1023_packets = dev->stats.rx_512_to_1023_packets;
|
|
|
|
stats->rx_1024_to_1522_packets = dev->stats.rx_1024_to_1522_packets;
|
|
|
|
stats->rx_1523_to_max_packets = dev->stats.rx_1523_to_max_packets;
|
|
|
|
|
2015-05-22 17:14:21 +01:00
|
|
|
rte_spinlock_unlock(&dev->stats_lock);
|
2015-07-01 11:49:12 +01:00
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-05-05 09:46:01 +01:00
|
|
|
static void
|
|
|
|
netdev_dpdk_convert_xstats(struct netdev_stats *stats,
|
2016-08-03 13:29:24 +01:00
|
|
|
const struct rte_eth_xstat *xstats,
|
|
|
|
const struct rte_eth_xstat_name *names,
|
2016-05-05 09:46:01 +01:00
|
|
|
const unsigned int size)
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < size; i++) {
|
2016-08-03 13:29:24 +01:00
|
|
|
if (strcmp(XSTAT_RX_64_PACKETS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->rx_1_to_64_packets = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_RX_65_TO_127_PACKETS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->rx_65_to_127_packets = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_RX_128_TO_255_PACKETS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->rx_128_to_255_packets = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_RX_256_TO_511_PACKETS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->rx_256_to_511_packets = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_RX_512_TO_1023_PACKETS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->rx_512_to_1023_packets = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_RX_1024_TO_1522_PACKETS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->rx_1024_to_1522_packets = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_RX_1523_TO_MAX_PACKETS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->rx_1523_to_max_packets = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_TX_64_PACKETS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->tx_1_to_64_packets = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_TX_65_TO_127_PACKETS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->tx_65_to_127_packets = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_TX_128_TO_255_PACKETS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->tx_128_to_255_packets = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_TX_256_TO_511_PACKETS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->tx_256_to_511_packets = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_TX_512_TO_1023_PACKETS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->tx_512_to_1023_packets = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_TX_1024_TO_1522_PACKETS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->tx_1024_to_1522_packets = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_TX_1523_TO_MAX_PACKETS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->tx_1523_to_max_packets = xstats[i].value;
|
2017-04-28 10:51:30 +01:00
|
|
|
} else if (strcmp(XSTAT_RX_MULTICAST_PACKETS, names[i].name) == 0) {
|
|
|
|
stats->multicast = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_TX_MULTICAST_PACKETS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->tx_multicast_packets = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_RX_BROADCAST_PACKETS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->rx_broadcast_packets = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_TX_BROADCAST_PACKETS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->tx_broadcast_packets = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_RX_UNDERSIZED_ERRORS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->rx_undersized_errors = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_RX_FRAGMENTED_ERRORS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->rx_fragmented_errors = xstats[i].value;
|
2016-08-03 13:29:24 +01:00
|
|
|
} else if (strcmp(XSTAT_RX_JABBER_ERRORS, names[i].name) == 0) {
|
2016-05-05 09:46:01 +01:00
|
|
|
stats->rx_jabber_errors = xstats[i].value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
static int
|
|
|
|
netdev_dpdk_get_stats(const struct netdev *netdev, struct netdev_stats *stats)
|
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
|
|
|
struct rte_eth_stats rte_stats;
|
|
|
|
bool gg;
|
|
|
|
|
|
|
|
netdev_dpdk_get_carrier(netdev, &gg);
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
|
2016-08-03 13:29:24 +01:00
|
|
|
struct rte_eth_xstat *rte_xstats = NULL;
|
|
|
|
struct rte_eth_xstat_name *rte_xstats_names = NULL;
|
|
|
|
int rte_xstats_len, rte_xstats_new_len, rte_xstats_ret;
|
2016-05-05 09:46:01 +01:00
|
|
|
|
|
|
|
if (rte_eth_stats_get(dev->port_id, &rte_stats)) {
|
2018-02-21 17:39:35 +03:00
|
|
|
VLOG_ERR("Can't get ETH statistics for port: "DPDK_PORT_ID_FMT,
|
|
|
|
dev->port_id);
|
2016-05-10 15:50:42 -07:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
2016-05-05 09:46:01 +01:00
|
|
|
return EPROTO;
|
|
|
|
}
|
|
|
|
|
2016-08-03 13:29:24 +01:00
|
|
|
/* Get length of statistics */
|
|
|
|
rte_xstats_len = rte_eth_xstats_get_names(dev->port_id, NULL, 0);
|
|
|
|
if (rte_xstats_len < 0) {
|
2018-02-21 17:39:35 +03:00
|
|
|
VLOG_WARN("Cannot get XSTATS values for port: "DPDK_PORT_ID_FMT,
|
|
|
|
dev->port_id);
|
2016-08-03 13:29:24 +01:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/* Reserve memory for xstats names and values */
|
|
|
|
rte_xstats_names = xcalloc(rte_xstats_len, sizeof *rte_xstats_names);
|
|
|
|
rte_xstats = xcalloc(rte_xstats_len, sizeof *rte_xstats);
|
|
|
|
|
|
|
|
/* Retreive xstats names */
|
|
|
|
rte_xstats_new_len = rte_eth_xstats_get_names(dev->port_id,
|
|
|
|
rte_xstats_names,
|
|
|
|
rte_xstats_len);
|
|
|
|
if (rte_xstats_new_len != rte_xstats_len) {
|
2018-02-21 17:39:35 +03:00
|
|
|
VLOG_WARN("Cannot get XSTATS names for port: "DPDK_PORT_ID_FMT,
|
|
|
|
dev->port_id);
|
2016-08-03 13:29:24 +01:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/* Retreive xstats values */
|
|
|
|
memset(rte_xstats, 0xff, sizeof *rte_xstats * rte_xstats_len);
|
|
|
|
rte_xstats_ret = rte_eth_xstats_get(dev->port_id, rte_xstats,
|
|
|
|
rte_xstats_len);
|
|
|
|
if (rte_xstats_ret > 0 && rte_xstats_ret <= rte_xstats_len) {
|
|
|
|
netdev_dpdk_convert_xstats(stats, rte_xstats, rte_xstats_names,
|
|
|
|
rte_xstats_len);
|
2016-05-05 09:46:01 +01:00
|
|
|
} else {
|
2018-02-21 17:39:35 +03:00
|
|
|
VLOG_WARN("Cannot get XSTATS values for port: "DPDK_PORT_ID_FMT,
|
|
|
|
dev->port_id);
|
2016-05-05 09:46:01 +01:00
|
|
|
}
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2016-08-03 13:29:24 +01:00
|
|
|
out:
|
|
|
|
free(rte_xstats);
|
|
|
|
free(rte_xstats_names);
|
|
|
|
|
2014-09-12 16:00:50 -07:00
|
|
|
stats->rx_packets = rte_stats.ipackets;
|
|
|
|
stats->tx_packets = rte_stats.opackets;
|
|
|
|
stats->rx_bytes = rte_stats.ibytes;
|
|
|
|
stats->tx_bytes = rte_stats.obytes;
|
2017-02-16 15:31:22 +00:00
|
|
|
stats->rx_errors = rte_stats.ierrors;
|
2014-09-12 16:00:50 -07:00
|
|
|
stats->tx_errors = rte_stats.oerrors;
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2015-05-22 17:14:21 +01:00
|
|
|
rte_spinlock_lock(&dev->stats_lock);
|
2014-09-12 16:00:50 -07:00
|
|
|
stats->tx_dropped = dev->stats.tx_dropped;
|
2016-05-24 17:36:51 +01:00
|
|
|
stats->rx_dropped = dev->stats.rx_dropped;
|
2015-05-22 17:14:21 +01:00
|
|
|
rte_spinlock_unlock(&dev->stats_lock);
|
2015-07-01 11:49:12 +01:00
|
|
|
|
|
|
|
/* These are the available DPDK counters for packets not received due to
|
|
|
|
* local resource constraints in DPDK and NIC respectively. */
|
2016-05-24 17:36:51 +01:00
|
|
|
stats->rx_dropped += rte_stats.rx_nombuf + rte_stats.imissed;
|
2015-07-01 11:49:12 +01:00
|
|
|
stats->rx_missed_errors = rte_stats.imissed;
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-01-09 07:55:37 +00:00
|
|
|
static int
|
|
|
|
netdev_dpdk_get_custom_stats(const struct netdev *netdev,
|
|
|
|
struct netdev_custom_stats *custom_stats)
|
|
|
|
{
|
|
|
|
|
|
|
|
uint32_t i;
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
|
|
|
int rte_xstats_ret;
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
|
|
|
|
if (netdev_dpdk_configure_xstats(dev)) {
|
|
|
|
uint64_t *values = xcalloc(dev->rte_xstats_ids_size,
|
|
|
|
sizeof(uint64_t));
|
|
|
|
|
|
|
|
rte_xstats_ret =
|
|
|
|
rte_eth_xstats_get_by_id(dev->port_id, dev->rte_xstats_ids,
|
|
|
|
values, dev->rte_xstats_ids_size);
|
|
|
|
|
|
|
|
if (rte_xstats_ret > 0 &&
|
|
|
|
rte_xstats_ret <= dev->rte_xstats_ids_size) {
|
|
|
|
|
|
|
|
custom_stats->size = rte_xstats_ret;
|
|
|
|
custom_stats->counters =
|
|
|
|
(struct netdev_custom_counter *) xcalloc(rte_xstats_ret,
|
|
|
|
sizeof(struct netdev_custom_counter));
|
|
|
|
|
|
|
|
for (i = 0; i < rte_xstats_ret; i++) {
|
|
|
|
ovs_strlcpy(custom_stats->counters[i].name,
|
|
|
|
netdev_dpdk_get_xstat_name(dev,
|
|
|
|
dev->rte_xstats_ids[i]),
|
|
|
|
NETDEV_CUSTOM_STATS_NAME_SIZE);
|
|
|
|
custom_stats->counters[i].value = values[i];
|
|
|
|
}
|
|
|
|
} else {
|
2018-02-21 17:39:35 +03:00
|
|
|
VLOG_WARN("Cannot get XSTATS values for port: "DPDK_PORT_ID_FMT,
|
2018-01-09 07:55:37 +00:00
|
|
|
dev->port_id);
|
|
|
|
custom_stats->counters = NULL;
|
|
|
|
custom_stats->size = 0;
|
|
|
|
/* Let's clear statistics cache, so it will be
|
|
|
|
* reconfigured */
|
|
|
|
netdev_dpdk_clear_xstats(dev);
|
|
|
|
}
|
2018-01-22 19:24:26 +03:00
|
|
|
|
|
|
|
free(values);
|
2018-01-09 07:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
static int
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_get_features(const struct netdev *netdev,
|
2014-03-24 19:23:08 -07:00
|
|
|
enum netdev_features *current,
|
2016-10-13 23:18:20 +08:00
|
|
|
enum netdev_features *advertised,
|
|
|
|
enum netdev_features *supported,
|
|
|
|
enum netdev_features *peer)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2014-03-24 19:23:08 -07:00
|
|
|
struct rte_eth_link link;
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
link = dev->link;
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
|
2016-04-14 17:40:06 +01:00
|
|
|
if (link.link_duplex == ETH_LINK_HALF_DUPLEX) {
|
|
|
|
if (link.link_speed == ETH_SPEED_NUM_10M) {
|
2014-03-24 19:23:08 -07:00
|
|
|
*current = NETDEV_F_10MB_HD;
|
|
|
|
}
|
2016-04-14 17:40:06 +01:00
|
|
|
if (link.link_speed == ETH_SPEED_NUM_100M) {
|
2014-03-24 19:23:08 -07:00
|
|
|
*current = NETDEV_F_100MB_HD;
|
|
|
|
}
|
2016-04-14 17:40:06 +01:00
|
|
|
if (link.link_speed == ETH_SPEED_NUM_1G) {
|
2014-03-24 19:23:08 -07:00
|
|
|
*current = NETDEV_F_1GB_HD;
|
|
|
|
}
|
|
|
|
} else if (link.link_duplex == ETH_LINK_FULL_DUPLEX) {
|
2016-04-14 17:40:06 +01:00
|
|
|
if (link.link_speed == ETH_SPEED_NUM_10M) {
|
2014-03-24 19:23:08 -07:00
|
|
|
*current = NETDEV_F_10MB_FD;
|
|
|
|
}
|
2016-04-14 17:40:06 +01:00
|
|
|
if (link.link_speed == ETH_SPEED_NUM_100M) {
|
2014-03-24 19:23:08 -07:00
|
|
|
*current = NETDEV_F_100MB_FD;
|
|
|
|
}
|
2016-04-14 17:40:06 +01:00
|
|
|
if (link.link_speed == ETH_SPEED_NUM_1G) {
|
2014-03-24 19:23:08 -07:00
|
|
|
*current = NETDEV_F_1GB_FD;
|
|
|
|
}
|
2016-04-14 17:40:06 +01:00
|
|
|
if (link.link_speed == ETH_SPEED_NUM_10G) {
|
2014-03-24 19:23:08 -07:00
|
|
|
*current = NETDEV_F_10GB_FD;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-14 17:40:06 +01:00
|
|
|
if (link.link_autoneg) {
|
|
|
|
*current |= NETDEV_F_AUTONEG;
|
|
|
|
}
|
|
|
|
|
2016-10-13 23:18:20 +08:00
|
|
|
*advertised = *supported = *peer = 0;
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-05-24 17:36:51 +01:00
|
|
|
static struct ingress_policer *
|
|
|
|
netdev_dpdk_policer_construct(uint32_t rate, uint32_t burst)
|
|
|
|
{
|
|
|
|
struct ingress_policer *policer = NULL;
|
|
|
|
uint64_t rate_bytes;
|
|
|
|
uint64_t burst_bytes;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
policer = xmalloc(sizeof *policer);
|
|
|
|
rte_spinlock_init(&policer->policer_lock);
|
|
|
|
|
|
|
|
/* rte_meter requires bytes so convert kbits rate and burst to bytes. */
|
2017-08-25 14:35:31 -07:00
|
|
|
rate_bytes = rate * 1000ULL / 8;
|
|
|
|
burst_bytes = burst * 1000ULL / 8;
|
2016-05-24 17:36:51 +01:00
|
|
|
|
|
|
|
policer->app_srtcm_params.cir = rate_bytes;
|
|
|
|
policer->app_srtcm_params.cbs = burst_bytes;
|
|
|
|
policer->app_srtcm_params.ebs = 0;
|
|
|
|
err = rte_meter_srtcm_config(&policer->in_policer,
|
|
|
|
&policer->app_srtcm_params);
|
2016-09-29 11:27:03 +01:00
|
|
|
if (err) {
|
2016-05-24 17:36:51 +01:00
|
|
|
VLOG_ERR("Could not create rte meter for ingress policer");
|
2018-01-06 21:24:26 +08:00
|
|
|
free(policer);
|
2016-05-24 17:36:51 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return policer;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netdev_dpdk_set_policing(struct netdev* netdev, uint32_t policer_rate,
|
|
|
|
uint32_t policer_burst)
|
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
|
|
|
struct ingress_policer *policer;
|
|
|
|
|
|
|
|
/* Force to 0 if no rate specified,
|
|
|
|
* default to 8000 kbits if burst is 0,
|
|
|
|
* else stick with user-specified value.
|
|
|
|
*/
|
|
|
|
policer_burst = (!policer_rate ? 0
|
|
|
|
: !policer_burst ? 8000
|
|
|
|
: policer_burst);
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
|
|
|
|
policer = ovsrcu_get_protected(struct ingress_policer *,
|
|
|
|
&dev->ingress_policer);
|
|
|
|
|
|
|
|
if (dev->policer_rate == policer_rate &&
|
|
|
|
dev->policer_burst == policer_burst) {
|
|
|
|
/* Assume that settings haven't changed since we last set them. */
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Destroy any existing ingress policer for the device if one exists */
|
|
|
|
if (policer) {
|
|
|
|
ovsrcu_postpone(free, policer);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (policer_rate != 0) {
|
|
|
|
policer = netdev_dpdk_policer_construct(policer_rate, policer_burst);
|
|
|
|
} else {
|
|
|
|
policer = NULL;
|
|
|
|
}
|
|
|
|
ovsrcu_set(&dev->ingress_policer, policer);
|
|
|
|
dev->policer_rate = policer_rate;
|
|
|
|
dev->policer_burst = policer_burst;
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
static int
|
|
|
|
netdev_dpdk_get_ifindex(const struct netdev *netdev)
|
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
2017-04-03 13:27:47 +01:00
|
|
|
/* Calculate hash from the netdev name. Ensure that ifindex is a 24-bit
|
|
|
|
* postive integer to meet RFC 2863 recommendations.
|
|
|
|
*/
|
|
|
|
int ifindex = hash_string(netdev->name, 0) % 0xfffffe + 1;
|
2014-03-24 19:23:08 -07:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
|
|
|
|
return ifindex;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_get_carrier(const struct netdev *netdev, bool *carrier)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
check_link_status(dev);
|
|
|
|
*carrier = dev->link.link_status;
|
2015-03-05 13:42:04 -08:00
|
|
|
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_vhost_get_carrier(const struct netdev *netdev, bool *carrier)
|
2015-03-05 13:42:04 -08:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2015-03-05 13:42:04 -08:00
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
|
2016-08-03 13:29:24 +01:00
|
|
|
if (is_vhost_running(dev)) {
|
2015-03-05 13:42:04 -08:00
|
|
|
*carrier = 1;
|
|
|
|
} else {
|
|
|
|
*carrier = 0;
|
|
|
|
}
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static long long int
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_get_carrier_resets(const struct netdev *netdev)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2014-03-24 19:23:08 -07:00
|
|
|
long long int carrier_resets;
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
carrier_resets = dev->link_reset_cnt;
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
|
|
|
|
return carrier_resets;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_set_miimon(struct netdev *netdev OVS_UNUSED,
|
2014-03-24 19:23:08 -07:00
|
|
|
long long int interval OVS_UNUSED)
|
|
|
|
{
|
2015-02-13 10:00:58 +00:00
|
|
|
return EOPNOTSUPP;
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netdev_dpdk_update_flags__(struct netdev_dpdk *dev,
|
|
|
|
enum netdev_flags off, enum netdev_flags on,
|
2016-07-18 17:05:35 -07:00
|
|
|
enum netdev_flags *old_flagsp)
|
|
|
|
OVS_REQUIRES(dev->mutex)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
|
|
|
if ((off | on) & ~(NETDEV_UP | NETDEV_PROMISC)) {
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*old_flagsp = dev->flags;
|
|
|
|
dev->flags |= on;
|
|
|
|
dev->flags &= ~off;
|
|
|
|
|
|
|
|
if (dev->flags == *old_flagsp) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
if (dev->type == DPDK_DEV_ETH) {
|
|
|
|
if (dev->flags & NETDEV_PROMISC) {
|
|
|
|
rte_eth_promiscuous_enable(dev->port_id);
|
|
|
|
}
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2016-11-11 21:44:50 +08:00
|
|
|
netdev_change_seq_changed(&dev->up);
|
2016-06-02 12:42:39 +00:00
|
|
|
} else {
|
|
|
|
/* If DPDK_DEV_VHOST device's NETDEV_UP flag was changed and vhost is
|
|
|
|
* running then change netdev's change_seq to trigger link state
|
|
|
|
* update. */
|
|
|
|
|
|
|
|
if ((NETDEV_UP & ((*old_flagsp ^ on) | (*old_flagsp ^ off)))
|
2016-08-03 13:29:24 +01:00
|
|
|
&& is_vhost_running(dev)) {
|
2016-06-02 12:42:39 +00:00
|
|
|
netdev_change_seq_changed(&dev->up);
|
|
|
|
|
|
|
|
/* Clear statistics if device is getting up. */
|
|
|
|
if (NETDEV_UP & on) {
|
|
|
|
rte_spinlock_lock(&dev->stats_lock);
|
2016-09-29 11:27:03 +01:00
|
|
|
memset(&dev->stats, 0, sizeof dev->stats);
|
2016-06-02 12:42:39 +00:00
|
|
|
rte_spinlock_unlock(&dev->stats_lock);
|
|
|
|
}
|
|
|
|
}
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_update_flags(struct netdev *netdev,
|
2014-03-24 19:23:08 -07:00
|
|
|
enum netdev_flags off, enum netdev_flags on,
|
|
|
|
enum netdev_flags *old_flagsp)
|
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2014-03-24 19:23:08 -07:00
|
|
|
int error;
|
|
|
|
|
2016-03-16 14:44:18 -07:00
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
error = netdev_dpdk_update_flags__(dev, off, on, old_flagsp);
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2018-01-16 02:22:16 -02:00
|
|
|
static int
|
|
|
|
netdev_dpdk_vhost_user_get_status(const struct netdev *netdev,
|
|
|
|
struct smap *args)
|
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
|
|
|
|
bool client_mode = dev->vhost_driver_flags & RTE_VHOST_USER_CLIENT;
|
|
|
|
smap_add_format(args, "mode", "%s", client_mode ? "client" : "server");
|
|
|
|
|
|
|
|
int vid = netdev_dpdk_get_vid(dev);
|
|
|
|
if (vid < 0) {
|
|
|
|
smap_add_format(args, "status", "disconnected");
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
smap_add_format(args, "status", "connected");
|
|
|
|
}
|
|
|
|
|
|
|
|
char socket_name[PATH_MAX];
|
|
|
|
if (!rte_vhost_get_ifname(vid, socket_name, PATH_MAX)) {
|
|
|
|
smap_add_format(args, "socket", "%s", socket_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t features;
|
|
|
|
if (!rte_vhost_get_negotiated_features(vid, &features)) {
|
|
|
|
smap_add_format(args, "features", "0x%016"PRIx64, features);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t mtu;
|
|
|
|
if (!rte_vhost_get_mtu(vid, &mtu)) {
|
|
|
|
smap_add_format(args, "mtu", "%d", mtu);
|
|
|
|
}
|
|
|
|
|
|
|
|
int numa = rte_vhost_get_numa_node(vid);
|
|
|
|
if (numa >= 0) {
|
|
|
|
smap_add_format(args, "numa", "%d", numa);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t vring_num = rte_vhost_get_vring_num(vid);
|
|
|
|
if (vring_num) {
|
|
|
|
smap_add_format(args, "num_of_vrings", "%d", vring_num);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < vring_num; i++) {
|
|
|
|
struct rte_vhost_vring vring;
|
|
|
|
char vhost_vring[16];
|
|
|
|
|
|
|
|
rte_vhost_get_vhost_vring(vid, i, &vring);
|
|
|
|
snprintf(vhost_vring, 16, "vring_%d_size", i);
|
|
|
|
smap_add_format(args, vhost_vring, "%d", vring.size);
|
|
|
|
}
|
|
|
|
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
static int
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_get_status(const struct netdev *netdev, struct smap *args)
|
2014-03-24 19:23:08 -07:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2014-03-24 19:23:08 -07:00
|
|
|
struct rte_eth_dev_info dev_info;
|
|
|
|
|
2016-08-12 16:57:21 +01:00
|
|
|
if (!rte_eth_dev_is_valid_port(dev->port_id)) {
|
2014-03-24 19:23:08 -07:00
|
|
|
return ENODEV;
|
2016-08-12 16:57:21 +01:00
|
|
|
}
|
2014-03-24 19:23:08 -07:00
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
rte_eth_dev_info_get(dev->port_id, &dev_info);
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
|
2018-02-21 17:39:35 +03:00
|
|
|
smap_add_format(args, "port_no", DPDK_PORT_ID_FMT, dev->port_id);
|
2016-09-29 11:27:03 +01:00
|
|
|
smap_add_format(args, "numa_id", "%d",
|
|
|
|
rte_eth_dev_socket_id(dev->port_id));
|
2014-03-24 19:23:08 -07:00
|
|
|
smap_add_format(args, "driver_name", "%s", dev_info.driver_name);
|
|
|
|
smap_add_format(args, "min_rx_bufsize", "%u", dev_info.min_rx_bufsize);
|
2016-02-19 11:25:11 +00:00
|
|
|
smap_add_format(args, "max_rx_pktlen", "%u", dev->max_packet_len);
|
2014-03-24 19:23:08 -07:00
|
|
|
smap_add_format(args, "max_rx_queues", "%u", dev_info.max_rx_queues);
|
|
|
|
smap_add_format(args, "max_tx_queues", "%u", dev_info.max_tx_queues);
|
|
|
|
smap_add_format(args, "max_mac_addrs", "%u", dev_info.max_mac_addrs);
|
2016-09-29 11:27:03 +01:00
|
|
|
smap_add_format(args, "max_hash_mac_addrs", "%u",
|
|
|
|
dev_info.max_hash_mac_addrs);
|
2014-03-24 19:23:08 -07:00
|
|
|
smap_add_format(args, "max_vfs", "%u", dev_info.max_vfs);
|
|
|
|
smap_add_format(args, "max_vmdq_pools", "%u", dev_info.max_vmdq_pools);
|
|
|
|
|
2017-11-14 10:59:44 +00:00
|
|
|
/* Querying the DPDK library for iftype may be done in future, pending
|
|
|
|
* support; cf. RFC 3635 Section 3.2.4. */
|
|
|
|
enum { IF_TYPE_ETHERNETCSMACD = 6 };
|
|
|
|
|
|
|
|
smap_add_format(args, "if_type", "%"PRIu32, IF_TYPE_ETHERNETCSMACD);
|
|
|
|
smap_add_format(args, "if_descr", "%s %s", rte_version(),
|
|
|
|
dev_info.driver_name);
|
|
|
|
|
2015-12-02 23:30:16 -08:00
|
|
|
if (dev_info.pci_dev) {
|
|
|
|
smap_add_format(args, "pci-vendor_id", "0x%u",
|
|
|
|
dev_info.pci_dev->id.vendor_id);
|
|
|
|
smap_add_format(args, "pci-device_id", "0x%x",
|
|
|
|
dev_info.pci_dev->id.device_id);
|
|
|
|
}
|
2014-03-24 19:23:08 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
netdev_dpdk_set_admin_state__(struct netdev_dpdk *dev, bool admin_state)
|
|
|
|
OVS_REQUIRES(dev->mutex)
|
|
|
|
{
|
|
|
|
enum netdev_flags old_flags;
|
|
|
|
|
|
|
|
if (admin_state) {
|
|
|
|
netdev_dpdk_update_flags__(dev, 0, NETDEV_UP, &old_flags);
|
|
|
|
} else {
|
|
|
|
netdev_dpdk_update_flags__(dev, NETDEV_UP, 0, &old_flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
netdev_dpdk_set_admin_state(struct unixctl_conn *conn, int argc,
|
|
|
|
const char *argv[], void *aux OVS_UNUSED)
|
|
|
|
{
|
|
|
|
bool up;
|
|
|
|
|
|
|
|
if (!strcasecmp(argv[argc - 1], "up")) {
|
|
|
|
up = true;
|
|
|
|
} else if ( !strcasecmp(argv[argc - 1], "down")) {
|
|
|
|
up = false;
|
|
|
|
} else {
|
|
|
|
unixctl_command_reply_error(conn, "Invalid Admin State");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc > 2) {
|
|
|
|
struct netdev *netdev = netdev_from_name(argv[1]);
|
2017-11-23 16:48:25 +03:00
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
if (netdev && is_dpdk_class(netdev->netdev_class)) {
|
2017-11-23 16:48:25 +03:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2017-11-23 16:48:25 +03:00
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
netdev_dpdk_set_admin_state__(dev, up);
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
2014-03-24 19:23:08 -07:00
|
|
|
|
|
|
|
netdev_close(netdev);
|
|
|
|
} else {
|
|
|
|
unixctl_command_reply_error(conn, "Not a DPDK Interface");
|
|
|
|
netdev_close(netdev);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
2017-11-23 16:48:25 +03:00
|
|
|
struct netdev_dpdk *dev;
|
2014-03-24 19:23:08 -07:00
|
|
|
|
|
|
|
ovs_mutex_lock(&dpdk_mutex);
|
2017-11-23 16:48:25 +03:00
|
|
|
LIST_FOR_EACH (dev, list_node, &dpdk_list) {
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
netdev_dpdk_set_admin_state__(dev, up);
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|
|
|
|
ovs_mutex_unlock(&dpdk_mutex);
|
|
|
|
}
|
|
|
|
unixctl_command_reply(conn, "OK");
|
|
|
|
}
|
|
|
|
|
2017-08-01 17:04:29 -07:00
|
|
|
static void
|
|
|
|
netdev_dpdk_detach(struct unixctl_conn *conn, int argc OVS_UNUSED,
|
|
|
|
const char *argv[], void *aux OVS_UNUSED)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
char *response;
|
2017-10-20 13:37:00 +01:00
|
|
|
dpdk_port_t port_id;
|
2017-08-01 17:04:29 -07:00
|
|
|
char devname[RTE_ETH_NAME_MAX_LEN];
|
|
|
|
struct netdev_dpdk *dev;
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dpdk_mutex);
|
|
|
|
|
2017-11-27 17:25:49 +00:00
|
|
|
if (rte_eth_dev_get_port_by_name(argv[1], &port_id)) {
|
2017-08-01 17:04:29 -07:00
|
|
|
response = xasprintf("Device '%s' not found in DPDK", argv[1]);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev = netdev_dpdk_lookup_by_port_id(port_id);
|
|
|
|
if (dev) {
|
|
|
|
response = xasprintf("Device '%s' is being used by interface '%s'. "
|
|
|
|
"Remove it before detaching",
|
|
|
|
argv[1], netdev_get_name(&dev->up));
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
rte_eth_dev_close(port_id);
|
|
|
|
|
|
|
|
ret = rte_eth_dev_detach(port_id, devname);
|
|
|
|
if (ret < 0) {
|
|
|
|
response = xasprintf("Device '%s' can not be detached", argv[1]);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
response = xasprintf("Device '%s' has been detached", argv[1]);
|
|
|
|
|
|
|
|
ovs_mutex_unlock(&dpdk_mutex);
|
|
|
|
unixctl_command_reply(conn, response);
|
|
|
|
free(response);
|
|
|
|
return;
|
|
|
|
|
|
|
|
error:
|
|
|
|
ovs_mutex_unlock(&dpdk_mutex);
|
|
|
|
unixctl_command_reply_error(conn, response);
|
|
|
|
free(response);
|
|
|
|
}
|
|
|
|
|
2017-12-11 16:18:43 +03:00
|
|
|
static void
|
|
|
|
netdev_dpdk_get_mempool_info(struct unixctl_conn *conn,
|
|
|
|
int argc, const char *argv[],
|
|
|
|
void *aux OVS_UNUSED)
|
|
|
|
{
|
|
|
|
size_t size;
|
|
|
|
FILE *stream;
|
|
|
|
char *response = NULL;
|
|
|
|
struct netdev *netdev = NULL;
|
|
|
|
|
|
|
|
if (argc == 2) {
|
|
|
|
netdev = netdev_from_name(argv[1]);
|
|
|
|
if (!netdev || !is_dpdk_class(netdev->netdev_class)) {
|
|
|
|
unixctl_command_reply_error(conn, "Not a DPDK Interface");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stream = open_memstream(&response, &size);
|
|
|
|
if (!stream) {
|
|
|
|
response = xasprintf("Unable to open memstream: %s.",
|
|
|
|
ovs_strerror(errno));
|
|
|
|
unixctl_command_reply_error(conn, response);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (netdev) {
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
ovs_mutex_lock(&dpdk_mp_mutex);
|
|
|
|
|
|
|
|
rte_mempool_dump(stream, dev->mp);
|
|
|
|
|
|
|
|
ovs_mutex_unlock(&dpdk_mp_mutex);
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
} else {
|
|
|
|
ovs_mutex_lock(&dpdk_mp_mutex);
|
|
|
|
rte_mempool_list_dump(stream);
|
|
|
|
ovs_mutex_unlock(&dpdk_mp_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(stream);
|
|
|
|
|
|
|
|
unixctl_command_reply(conn, response);
|
|
|
|
out:
|
|
|
|
free(response);
|
|
|
|
netdev_close(netdev);
|
|
|
|
}
|
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
/*
|
|
|
|
* Set virtqueue flags so that we do not receive interrupts.
|
|
|
|
*/
|
|
|
|
static void
|
2016-08-03 13:29:24 +01:00
|
|
|
set_irq_status(int vid)
|
2015-03-05 13:42:04 -08:00
|
|
|
{
|
2016-01-26 16:58:14 -02:00
|
|
|
uint32_t i;
|
|
|
|
|
2017-08-01 16:14:10 -07:00
|
|
|
for (i = 0; i < rte_vhost_get_vring_num(vid); i++) {
|
|
|
|
rte_vhost_enable_guest_notification(vid, i, 0);
|
2016-01-26 16:58:14 -02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-24 17:14:43 +03:00
|
|
|
/*
|
|
|
|
* Fixes mapping for vhost-user tx queues. Must be called after each
|
2016-07-08 16:52:37 +03:00
|
|
|
* enabling/disabling of queues and n_txq modifications.
|
2016-02-24 17:14:43 +03:00
|
|
|
*/
|
|
|
|
static void
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_remap_txqs(struct netdev_dpdk *dev)
|
|
|
|
OVS_REQUIRES(dev->mutex)
|
2016-02-24 17:14:43 +03:00
|
|
|
{
|
|
|
|
int *enabled_queues, n_enabled = 0;
|
2016-07-08 16:52:37 +03:00
|
|
|
int i, k, total_txqs = dev->up.n_txq;
|
2016-02-24 17:14:43 +03:00
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
enabled_queues = xcalloc(total_txqs, sizeof *enabled_queues);
|
2016-02-24 17:14:43 +03:00
|
|
|
|
|
|
|
for (i = 0; i < total_txqs; i++) {
|
|
|
|
/* Enabled queues always mapped to themselves. */
|
2016-03-16 14:44:18 -07:00
|
|
|
if (dev->tx_q[i].map == i) {
|
2016-02-24 17:14:43 +03:00
|
|
|
enabled_queues[n_enabled++] = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n_enabled == 0 && total_txqs != 0) {
|
2016-03-29 09:20:41 +03:00
|
|
|
enabled_queues[0] = OVS_VHOST_QUEUE_DISABLED;
|
2016-02-24 17:14:43 +03:00
|
|
|
n_enabled = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
k = 0;
|
|
|
|
for (i = 0; i < total_txqs; i++) {
|
2016-03-16 14:44:18 -07:00
|
|
|
if (dev->tx_q[i].map != i) {
|
|
|
|
dev->tx_q[i].map = enabled_queues[k];
|
2016-02-24 17:14:43 +03:00
|
|
|
k = (k + 1) % n_enabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-19 10:22:30 +01:00
|
|
|
VLOG_DBG("TX queue mapping for %s\n", dev->vhost_id);
|
2016-02-24 17:14:43 +03:00
|
|
|
for (i = 0; i < total_txqs; i++) {
|
2016-03-16 14:44:18 -07:00
|
|
|
VLOG_DBG("%2d --> %2d", i, dev->tx_q[i].map);
|
2016-02-24 17:14:43 +03:00
|
|
|
}
|
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
free(enabled_queues);
|
2016-02-24 17:14:43 +03:00
|
|
|
}
|
2016-01-26 16:58:14 -02:00
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
/*
|
|
|
|
* A new virtio-net device is added to a vhost port.
|
|
|
|
*/
|
|
|
|
static int
|
2016-08-03 13:29:24 +01:00
|
|
|
new_device(int vid)
|
2015-03-05 13:42:04 -08:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev;
|
2015-03-05 13:42:04 -08:00
|
|
|
bool exists = false;
|
2016-06-13 11:10:09 +01:00
|
|
|
int newnode = 0;
|
2016-08-03 13:29:24 +01:00
|
|
|
char ifname[IF_NAME_SZ];
|
|
|
|
|
2016-09-29 11:27:03 +01:00
|
|
|
rte_vhost_get_ifname(vid, ifname, sizeof ifname);
|
2015-03-05 13:42:04 -08:00
|
|
|
|
|
|
|
ovs_mutex_lock(&dpdk_mutex);
|
|
|
|
/* Add device to the vhost port with the same name as that passed down. */
|
2016-03-16 14:44:18 -07:00
|
|
|
LIST_FOR_EACH(dev, list_node, &dpdk_list) {
|
2016-08-15 16:11:26 +01:00
|
|
|
ovs_mutex_lock(&dev->mutex);
|
2016-08-19 10:22:30 +01:00
|
|
|
if (strncmp(ifname, dev->vhost_id, IF_NAME_SZ) == 0) {
|
2017-08-01 16:14:10 -07:00
|
|
|
uint32_t qp_num = rte_vhost_get_vring_num(vid)/VIRTIO_QNUM;
|
2016-06-13 11:10:09 +01:00
|
|
|
|
|
|
|
/* Get NUMA information */
|
2016-08-03 13:29:24 +01:00
|
|
|
newnode = rte_vhost_get_numa_node(vid);
|
|
|
|
if (newnode == -1) {
|
2016-08-17 13:17:03 +01:00
|
|
|
#ifdef VHOST_NUMA
|
2016-06-13 11:10:09 +01:00
|
|
|
VLOG_INFO("Error getting NUMA info for vHost Device '%s'",
|
2016-08-03 13:29:24 +01:00
|
|
|
ifname);
|
2016-08-17 13:17:03 +01:00
|
|
|
#endif
|
2016-06-13 11:10:09 +01:00
|
|
|
newnode = dev->socket_id;
|
|
|
|
}
|
|
|
|
|
2016-08-08 14:19:45 +03:00
|
|
|
if (dev->requested_n_txq != qp_num
|
|
|
|
|| dev->requested_n_rxq != qp_num
|
|
|
|
|| dev->requested_socket_id != newnode) {
|
|
|
|
dev->requested_socket_id = newnode;
|
|
|
|
dev->requested_n_rxq = qp_num;
|
|
|
|
dev->requested_n_txq = qp_num;
|
|
|
|
netdev_request_reconfigure(&dev->up);
|
|
|
|
} else {
|
|
|
|
/* Reconfiguration not required. */
|
|
|
|
dev->vhost_reconfigured = true;
|
|
|
|
}
|
2016-07-08 16:52:37 +03:00
|
|
|
|
2016-08-03 13:29:24 +01:00
|
|
|
ovsrcu_index_set(&dev->vid, vid);
|
2016-07-08 16:52:37 +03:00
|
|
|
exists = true;
|
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
/* Disable notifications. */
|
2016-08-03 13:29:24 +01:00
|
|
|
set_irq_status(vid);
|
2016-06-02 12:42:39 +00:00
|
|
|
netdev_change_seq_changed(&dev->up);
|
2016-03-16 14:44:18 -07:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
2015-03-05 13:42:04 -08:00
|
|
|
break;
|
|
|
|
}
|
2016-08-15 16:11:26 +01:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
2015-03-05 13:42:04 -08:00
|
|
|
}
|
|
|
|
ovs_mutex_unlock(&dpdk_mutex);
|
|
|
|
|
|
|
|
if (!exists) {
|
2016-08-03 13:29:24 +01:00
|
|
|
VLOG_INFO("vHost Device '%s' can't be added - name not found", ifname);
|
2015-03-05 13:42:04 -08:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-08-03 13:29:24 +01:00
|
|
|
VLOG_INFO("vHost Device '%s' has been added on numa node %i",
|
|
|
|
ifname, newnode);
|
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-03-29 09:20:41 +03:00
|
|
|
/* Clears mapping for all available queues of vhost interface. */
|
|
|
|
static void
|
|
|
|
netdev_dpdk_txq_map_clear(struct netdev_dpdk *dev)
|
|
|
|
OVS_REQUIRES(dev->mutex)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2016-07-08 16:52:37 +03:00
|
|
|
for (i = 0; i < dev->up.n_txq; i++) {
|
2016-03-29 09:20:41 +03:00
|
|
|
dev->tx_q[i].map = OVS_VHOST_QUEUE_MAP_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
/*
|
|
|
|
* Remove a virtio-net device from the specific vhost port. Use dev->remove
|
|
|
|
* flag to stop any more packets from being sent or received to/from a VM and
|
|
|
|
* ensure all currently queued packets have been sent/received before removing
|
|
|
|
* the device.
|
|
|
|
*/
|
|
|
|
static void
|
2016-08-03 13:29:24 +01:00
|
|
|
destroy_device(int vid)
|
2015-03-05 13:42:04 -08:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev;
|
2016-02-05 17:07:16 +00:00
|
|
|
bool exists = false;
|
2016-08-03 13:29:24 +01:00
|
|
|
char ifname[IF_NAME_SZ];
|
|
|
|
|
2016-09-29 11:27:03 +01:00
|
|
|
rte_vhost_get_ifname(vid, ifname, sizeof ifname);
|
2015-03-05 13:42:04 -08:00
|
|
|
|
|
|
|
ovs_mutex_lock(&dpdk_mutex);
|
2016-03-16 14:44:18 -07:00
|
|
|
LIST_FOR_EACH (dev, list_node, &dpdk_list) {
|
2016-08-03 13:29:24 +01:00
|
|
|
if (netdev_dpdk_get_vid(dev) == vid) {
|
2015-03-05 13:42:04 -08:00
|
|
|
|
2016-03-16 14:44:18 -07:00
|
|
|
ovs_mutex_lock(&dev->mutex);
|
2016-08-03 13:29:24 +01:00
|
|
|
dev->vhost_reconfigured = false;
|
|
|
|
ovsrcu_index_set(&dev->vid, -1);
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_txq_map_clear(dev);
|
2016-07-08 16:52:37 +03:00
|
|
|
|
2016-06-02 12:42:39 +00:00
|
|
|
netdev_change_seq_changed(&dev->up);
|
2016-03-16 14:44:18 -07:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
2016-07-08 16:52:37 +03:00
|
|
|
exists = true;
|
2016-02-05 17:07:16 +00:00
|
|
|
break;
|
2015-03-05 13:42:04 -08:00
|
|
|
}
|
|
|
|
}
|
2016-02-05 17:07:16 +00:00
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
ovs_mutex_unlock(&dpdk_mutex);
|
|
|
|
|
2016-08-03 13:29:24 +01:00
|
|
|
if (exists) {
|
2016-02-05 17:07:16 +00:00
|
|
|
/*
|
|
|
|
* Wait for other threads to quiesce after setting the 'virtio_dev'
|
|
|
|
* to NULL, before returning.
|
|
|
|
*/
|
|
|
|
ovsrcu_synchronize();
|
|
|
|
/*
|
|
|
|
* As call to ovsrcu_synchronize() will end the quiescent state,
|
|
|
|
* put thread back into quiescent state before returning.
|
|
|
|
*/
|
|
|
|
ovsrcu_quiesce_start();
|
2016-08-03 13:29:24 +01:00
|
|
|
VLOG_INFO("vHost Device '%s' has been removed", ifname);
|
2016-02-05 17:07:16 +00:00
|
|
|
} else {
|
2016-08-03 13:29:24 +01:00
|
|
|
VLOG_INFO("vHost Device '%s' not found", ifname);
|
2016-02-05 17:07:16 +00:00
|
|
|
}
|
2015-03-05 13:42:04 -08:00
|
|
|
}
|
|
|
|
|
2016-02-24 17:14:43 +03:00
|
|
|
static int
|
2016-08-03 13:29:24 +01:00
|
|
|
vring_state_changed(int vid, uint16_t queue_id, int enable)
|
2016-02-24 17:14:43 +03:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev;
|
2016-02-24 17:14:43 +03:00
|
|
|
bool exists = false;
|
|
|
|
int qid = queue_id / VIRTIO_QNUM;
|
2016-08-03 13:29:24 +01:00
|
|
|
char ifname[IF_NAME_SZ];
|
|
|
|
|
2016-09-29 11:27:03 +01:00
|
|
|
rte_vhost_get_ifname(vid, ifname, sizeof ifname);
|
2016-02-24 17:14:43 +03:00
|
|
|
|
|
|
|
if (queue_id % VIRTIO_QNUM == VIRTIO_TXQ) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dpdk_mutex);
|
2016-03-16 14:44:18 -07:00
|
|
|
LIST_FOR_EACH (dev, list_node, &dpdk_list) {
|
2016-08-15 16:11:26 +01:00
|
|
|
ovs_mutex_lock(&dev->mutex);
|
2016-08-19 10:22:30 +01:00
|
|
|
if (strncmp(ifname, dev->vhost_id, IF_NAME_SZ) == 0) {
|
2016-02-24 17:14:43 +03:00
|
|
|
if (enable) {
|
2016-03-16 14:44:18 -07:00
|
|
|
dev->tx_q[qid].map = qid;
|
2016-02-24 17:14:43 +03:00
|
|
|
} else {
|
2016-03-16 14:44:18 -07:00
|
|
|
dev->tx_q[qid].map = OVS_VHOST_QUEUE_DISABLED;
|
2016-02-24 17:14:43 +03:00
|
|
|
}
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_remap_txqs(dev);
|
2016-02-24 17:14:43 +03:00
|
|
|
exists = true;
|
2016-03-16 14:44:18 -07:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
2016-02-24 17:14:43 +03:00
|
|
|
break;
|
|
|
|
}
|
2016-08-15 16:11:26 +01:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
2016-02-24 17:14:43 +03:00
|
|
|
}
|
|
|
|
ovs_mutex_unlock(&dpdk_mutex);
|
|
|
|
|
|
|
|
if (exists) {
|
2016-08-03 13:29:24 +01:00
|
|
|
VLOG_INFO("State of queue %d ( tx_qid %d ) of vhost device '%s'"
|
|
|
|
"changed to \'%s\'", queue_id, qid, ifname,
|
2016-03-16 14:44:18 -07:00
|
|
|
(enable == 1) ? "enabled" : "disabled");
|
2016-02-24 17:14:43 +03:00
|
|
|
} else {
|
2016-08-03 13:29:24 +01:00
|
|
|
VLOG_INFO("vHost Device '%s' not found", ifname);
|
2016-02-24 17:14:43 +03:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-04-19 19:40:44 +02:00
|
|
|
/*
|
|
|
|
* Retrieve the DPDK virtio device ID (vid) associated with a vhostuser
|
|
|
|
* or vhostuserclient netdev.
|
|
|
|
*
|
|
|
|
* Returns a value greater or equal to zero for a valid vid or '-1' if
|
|
|
|
* there is no valid vid associated. A vid of '-1' must not be used in
|
|
|
|
* rte_vhost_ APi calls.
|
|
|
|
*
|
|
|
|
* Once obtained and validated, a vid can be used by a PMD for multiple
|
|
|
|
* subsequent rte_vhost API calls until the PMD quiesces. A PMD should
|
|
|
|
* not fetch the vid again for each of a series of API calls.
|
|
|
|
*/
|
|
|
|
|
2016-08-03 13:29:24 +01:00
|
|
|
int
|
|
|
|
netdev_dpdk_get_vid(const struct netdev_dpdk *dev)
|
2015-03-05 13:42:04 -08:00
|
|
|
{
|
2016-08-03 13:29:24 +01:00
|
|
|
return ovsrcu_index_get(&dev->vid);
|
2015-03-05 13:42:04 -08:00
|
|
|
}
|
|
|
|
|
2016-05-24 17:36:51 +01:00
|
|
|
struct ingress_policer *
|
|
|
|
netdev_dpdk_get_ingress_policer(const struct netdev_dpdk *dev)
|
|
|
|
{
|
|
|
|
return ovsrcu_get(struct ingress_policer *, &dev->ingress_policer);
|
|
|
|
}
|
|
|
|
|
2015-03-05 13:42:04 -08:00
|
|
|
static int
|
2016-10-04 17:58:05 -07:00
|
|
|
netdev_dpdk_class_init(void)
|
2015-06-04 06:51:40 -07:00
|
|
|
{
|
2016-10-04 17:58:05 -07:00
|
|
|
static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
|
|
|
|
|
|
|
|
/* This function can be called for different classes. The initialization
|
|
|
|
* needs to be done only once */
|
|
|
|
if (ovsthread_once_start(&once)) {
|
|
|
|
ovs_thread_create("dpdk_watchdog", dpdk_watchdog, NULL);
|
|
|
|
unixctl_command_register("netdev-dpdk/set-admin-state",
|
|
|
|
"[netdev] up|down", 1, 2,
|
|
|
|
netdev_dpdk_set_admin_state, NULL);
|
|
|
|
|
2017-08-01 17:04:29 -07:00
|
|
|
unixctl_command_register("netdev-dpdk/detach",
|
|
|
|
"pci address of device", 1, 1,
|
|
|
|
netdev_dpdk_detach, NULL);
|
|
|
|
|
2017-12-11 16:18:43 +03:00
|
|
|
unixctl_command_register("netdev-dpdk/get-mempool-info",
|
|
|
|
"[netdev]", 0, 1,
|
|
|
|
netdev_dpdk_get_mempool_info, NULL);
|
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
ovsthread_once_done(&once);
|
|
|
|
}
|
2016-04-14 17:40:06 +01:00
|
|
|
|
2015-06-04 06:51:40 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-07-16 17:10:59 -07:00
|
|
|
|
2014-07-11 13:37:11 +01:00
|
|
|
/* Client Rings */
|
|
|
|
|
|
|
|
static int
|
|
|
|
dpdk_ring_create(const char dev_name[], unsigned int port_no,
|
2017-05-19 16:37:32 +03:00
|
|
|
dpdk_port_t *eth_port_id)
|
2014-07-11 13:37:11 +01:00
|
|
|
{
|
2017-01-03 18:21:29 +00:00
|
|
|
struct dpdk_ring *ring_pair;
|
2016-10-04 17:58:05 -07:00
|
|
|
char *ring_name;
|
2017-01-05 10:42:08 +00:00
|
|
|
int port_id;
|
2014-07-11 13:37:11 +01:00
|
|
|
|
2017-01-03 18:21:29 +00:00
|
|
|
ring_pair = dpdk_rte_mzalloc(sizeof *ring_pair);
|
|
|
|
if (!ring_pair) {
|
2014-07-11 13:37:11 +01:00
|
|
|
return ENOMEM;
|
|
|
|
}
|
|
|
|
|
2014-10-14 19:01:49 +02:00
|
|
|
/* XXX: Add support for multiquque ring. */
|
2016-10-04 17:58:05 -07:00
|
|
|
ring_name = xasprintf("%s_tx", dev_name);
|
2014-07-11 13:37:11 +01:00
|
|
|
|
2015-11-16 23:24:47 +01:00
|
|
|
/* Create single producer tx ring, netdev does explicit locking. */
|
2017-01-03 18:21:29 +00:00
|
|
|
ring_pair->cring_tx = rte_ring_create(ring_name, DPDK_RING_SIZE, SOCKET0,
|
2015-11-16 23:24:47 +01:00
|
|
|
RING_F_SP_ENQ);
|
2016-10-04 17:58:05 -07:00
|
|
|
free(ring_name);
|
2017-01-03 18:21:29 +00:00
|
|
|
if (ring_pair->cring_tx == NULL) {
|
|
|
|
rte_free(ring_pair);
|
2014-07-11 13:37:11 +01:00
|
|
|
return ENOMEM;
|
|
|
|
}
|
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
ring_name = xasprintf("%s_rx", dev_name);
|
2014-07-11 13:37:11 +01:00
|
|
|
|
2015-11-16 23:24:47 +01:00
|
|
|
/* Create single consumer rx ring, netdev does explicit locking. */
|
2017-01-03 18:21:29 +00:00
|
|
|
ring_pair->cring_rx = rte_ring_create(ring_name, DPDK_RING_SIZE, SOCKET0,
|
2015-11-16 23:24:47 +01:00
|
|
|
RING_F_SC_DEQ);
|
2016-10-04 17:58:05 -07:00
|
|
|
free(ring_name);
|
2017-01-03 18:21:29 +00:00
|
|
|
if (ring_pair->cring_rx == NULL) {
|
|
|
|
rte_free(ring_pair);
|
2014-07-11 13:37:11 +01:00
|
|
|
return ENOMEM;
|
|
|
|
}
|
|
|
|
|
2017-01-05 10:42:08 +00:00
|
|
|
port_id = rte_eth_from_rings(dev_name, &ring_pair->cring_rx, 1,
|
|
|
|
&ring_pair->cring_tx, 1, SOCKET0);
|
2014-08-12 10:43:35 -07:00
|
|
|
|
2017-01-05 10:42:08 +00:00
|
|
|
if (port_id < 0) {
|
2017-01-03 18:21:29 +00:00
|
|
|
rte_free(ring_pair);
|
2014-07-11 13:37:11 +01:00
|
|
|
return ENODEV;
|
|
|
|
}
|
|
|
|
|
2017-01-03 18:21:29 +00:00
|
|
|
ring_pair->user_port_id = port_no;
|
2017-01-05 10:42:08 +00:00
|
|
|
ring_pair->eth_port_id = port_id;
|
|
|
|
*eth_port_id = port_id;
|
|
|
|
|
2017-01-03 18:21:29 +00:00
|
|
|
ovs_list_push_back(&dpdk_ring_list, &ring_pair->list_node);
|
2014-07-11 13:37:11 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2017-05-19 16:37:32 +03:00
|
|
|
dpdk_ring_open(const char dev_name[], dpdk_port_t *eth_port_id)
|
2016-07-18 17:05:35 -07:00
|
|
|
OVS_REQUIRES(dpdk_mutex)
|
2014-07-11 13:37:11 +01:00
|
|
|
{
|
2017-01-03 18:21:29 +00:00
|
|
|
struct dpdk_ring *ring_pair;
|
2014-07-11 13:37:11 +01:00
|
|
|
unsigned int port_no;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
/* Names always start with "dpdkr" */
|
|
|
|
err = dpdk_dev_parse_name(dev_name, "dpdkr", &port_no);
|
|
|
|
if (err) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2016-09-29 11:27:03 +01:00
|
|
|
/* Look through our list to find the device */
|
2017-01-03 18:21:29 +00:00
|
|
|
LIST_FOR_EACH (ring_pair, list_node, &dpdk_ring_list) {
|
|
|
|
if (ring_pair->user_port_id == port_no) {
|
2015-03-05 13:42:04 -08:00
|
|
|
VLOG_INFO("Found dpdk ring device %s:", dev_name);
|
2016-09-29 11:27:03 +01:00
|
|
|
/* Really all that is needed */
|
2017-01-03 18:21:29 +00:00
|
|
|
*eth_port_id = ring_pair->eth_port_id;
|
2014-07-11 13:37:11 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Need to create the device rings */
|
|
|
|
return dpdk_ring_create(dev_name, port_no, eth_port_id);
|
|
|
|
}
|
|
|
|
|
2014-10-14 19:01:49 +02:00
|
|
|
static int
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_ring_send(struct netdev *netdev, int qid,
|
2017-12-14 14:59:25 +03:00
|
|
|
struct dp_packet_batch *batch, bool concurrent_txq)
|
2014-10-14 19:01:49 +02:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2017-09-22 02:05:49 -07:00
|
|
|
struct dp_packet *packet;
|
2015-04-13 06:36:56 -07:00
|
|
|
|
2016-09-29 11:27:03 +01:00
|
|
|
/* When using 'dpdkr' and sending to a DPDK ring, we want to ensure that
|
|
|
|
* the rss hash field is clear. This is because the same mbuf may be
|
|
|
|
* modified by the consumer of the ring and return into the datapath
|
|
|
|
* without recalculating the RSS hash. */
|
2018-02-27 10:41:30 -08:00
|
|
|
DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
|
2017-09-22 02:05:49 -07:00
|
|
|
dp_packet_mbuf_rss_flag_reset(packet);
|
2015-04-13 06:36:56 -07:00
|
|
|
}
|
2014-10-14 19:01:49 +02:00
|
|
|
|
2017-12-14 14:59:25 +03:00
|
|
|
netdev_dpdk_send__(dev, qid, batch, concurrent_txq);
|
2014-10-14 19:01:49 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-07-11 13:37:11 +01:00
|
|
|
static int
|
|
|
|
netdev_dpdk_ring_construct(struct netdev *netdev)
|
|
|
|
{
|
2017-05-19 16:37:32 +03:00
|
|
|
dpdk_port_t port_no = 0;
|
2014-07-11 13:37:11 +01:00
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dpdk_mutex);
|
|
|
|
|
|
|
|
err = dpdk_ring_open(netdev->name, &port_no);
|
|
|
|
if (err) {
|
|
|
|
goto unlock_dpdk;
|
|
|
|
}
|
|
|
|
|
2016-11-15 15:40:49 -08:00
|
|
|
err = common_construct(netdev, port_no, DPDK_DEV_ETH,
|
|
|
|
rte_eth_dev_socket_id(port_no));
|
2014-07-11 13:37:11 +01:00
|
|
|
unlock_dpdk:
|
|
|
|
ovs_mutex_unlock(&dpdk_mutex);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2016-03-02 20:35:54 +00:00
|
|
|
/* QoS Functions */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize QoS configuration operations.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
qos_conf_init(struct qos_conf *conf, const struct dpdk_qos_ops *ops)
|
|
|
|
{
|
|
|
|
conf->ops = ops;
|
2016-10-04 17:58:05 -07:00
|
|
|
rte_spinlock_init(&conf->lock);
|
2016-03-02 20:35:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Search existing QoS operations in qos_ops and compare each set of
|
|
|
|
* operations qos_name to name. Return a dpdk_qos_ops pointer to a match,
|
|
|
|
* else return NULL
|
|
|
|
*/
|
|
|
|
static const struct dpdk_qos_ops *
|
|
|
|
qos_lookup_name(const char *name)
|
|
|
|
{
|
|
|
|
const struct dpdk_qos_ops *const *opsp;
|
|
|
|
|
|
|
|
for (opsp = qos_confs; *opsp != NULL; opsp++) {
|
|
|
|
const struct dpdk_qos_ops *ops = *opsp;
|
|
|
|
if (!strcmp(name, ops->qos_name)) {
|
|
|
|
return ops;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netdev_dpdk_get_qos_types(const struct netdev *netdev OVS_UNUSED,
|
|
|
|
struct sset *types)
|
|
|
|
{
|
|
|
|
const struct dpdk_qos_ops *const *opsp;
|
|
|
|
|
|
|
|
for (opsp = qos_confs; *opsp != NULL; opsp++) {
|
|
|
|
const struct dpdk_qos_ops *ops = *opsp;
|
|
|
|
if (ops->qos_construct && ops->qos_name[0] != '\0') {
|
|
|
|
sset_add(types, ops->qos_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-03-16 14:44:18 -07:00
|
|
|
netdev_dpdk_get_qos(const struct netdev *netdev,
|
2016-03-02 20:35:54 +00:00
|
|
|
const char **typep, struct smap *details)
|
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2016-10-04 17:58:05 -07:00
|
|
|
struct qos_conf *qos_conf;
|
2016-03-02 20:35:54 +00:00
|
|
|
int error = 0;
|
|
|
|
|
2016-03-16 14:44:18 -07:00
|
|
|
ovs_mutex_lock(&dev->mutex);
|
2016-10-04 17:58:05 -07:00
|
|
|
qos_conf = ovsrcu_get_protected(struct qos_conf *, &dev->qos_conf);
|
|
|
|
if (qos_conf) {
|
|
|
|
*typep = qos_conf->ops->qos_name;
|
|
|
|
error = (qos_conf->ops->qos_get
|
|
|
|
? qos_conf->ops->qos_get(qos_conf, details): 0);
|
2016-08-02 15:46:59 +02:00
|
|
|
} else {
|
|
|
|
/* No QoS configuration set, return an empty string */
|
|
|
|
*typep = "";
|
2016-03-02 20:35:54 +00:00
|
|
|
}
|
2016-03-16 14:44:18 -07:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
2016-03-02 20:35:54 +00:00
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-10-04 17:58:05 -07:00
|
|
|
netdev_dpdk_set_qos(struct netdev *netdev, const char *type,
|
|
|
|
const struct smap *details)
|
2016-03-02 20:35:54 +00:00
|
|
|
{
|
2016-03-16 14:44:18 -07:00
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2016-03-02 20:35:54 +00:00
|
|
|
const struct dpdk_qos_ops *new_ops = NULL;
|
2016-10-04 17:58:05 -07:00
|
|
|
struct qos_conf *qos_conf, *new_qos_conf = NULL;
|
2016-03-02 20:35:54 +00:00
|
|
|
int error = 0;
|
|
|
|
|
2016-03-16 14:44:18 -07:00
|
|
|
ovs_mutex_lock(&dev->mutex);
|
2016-03-02 20:35:54 +00:00
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
qos_conf = ovsrcu_get_protected(struct qos_conf *, &dev->qos_conf);
|
2016-03-02 20:35:54 +00:00
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
new_ops = qos_lookup_name(type);
|
|
|
|
|
|
|
|
if (!new_ops || !new_ops->qos_construct) {
|
|
|
|
new_qos_conf = NULL;
|
|
|
|
if (type && type[0]) {
|
|
|
|
error = EOPNOTSUPP;
|
2016-03-02 20:35:54 +00:00
|
|
|
}
|
2016-10-31 14:52:43 -07:00
|
|
|
} else if (qos_conf && qos_conf->ops == new_ops
|
2016-10-04 17:58:05 -07:00
|
|
|
&& qos_conf->ops->qos_is_equal(qos_conf, details)) {
|
|
|
|
new_qos_conf = qos_conf;
|
2016-03-02 20:35:54 +00:00
|
|
|
} else {
|
2016-10-04 17:58:05 -07:00
|
|
|
error = new_ops->qos_construct(details, &new_qos_conf);
|
2016-08-09 18:20:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (error) {
|
2016-10-04 17:58:05 -07:00
|
|
|
VLOG_ERR("Failed to set QoS type %s on port %s: %s",
|
|
|
|
type, netdev->name, rte_strerror(error));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (new_qos_conf != qos_conf) {
|
|
|
|
ovsrcu_set(&dev->qos_conf, new_qos_conf);
|
|
|
|
if (qos_conf) {
|
|
|
|
ovsrcu_postpone(qos_conf->ops->qos_destruct, qos_conf);
|
|
|
|
}
|
2016-03-02 20:35:54 +00:00
|
|
|
}
|
|
|
|
|
2016-03-16 14:44:18 -07:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
2016-10-04 17:58:05 -07:00
|
|
|
|
2016-03-02 20:35:54 +00:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* egress-policer details */
|
|
|
|
|
|
|
|
struct egress_policer {
|
|
|
|
struct qos_conf qos_conf;
|
|
|
|
struct rte_meter_srtcm_params app_srtcm_params;
|
|
|
|
struct rte_meter_srtcm egress_meter;
|
|
|
|
};
|
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
static void
|
|
|
|
egress_policer_details_to_param(const struct smap *details,
|
|
|
|
struct rte_meter_srtcm_params *params)
|
2016-03-02 20:35:54 +00:00
|
|
|
{
|
2016-10-04 17:58:05 -07:00
|
|
|
memset(params, 0, sizeof *params);
|
|
|
|
params->cir = smap_get_ullong(details, "cir", 0);
|
|
|
|
params->cbs = smap_get_ullong(details, "cbs", 0);
|
|
|
|
params->ebs = 0;
|
2016-03-02 20:35:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-10-04 17:58:05 -07:00
|
|
|
egress_policer_qos_construct(const struct smap *details,
|
|
|
|
struct qos_conf **conf)
|
2016-03-02 20:35:54 +00:00
|
|
|
{
|
|
|
|
struct egress_policer *policer;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
policer = xmalloc(sizeof *policer);
|
|
|
|
qos_conf_init(&policer->qos_conf, &egress_policer_ops);
|
2016-10-04 17:58:05 -07:00
|
|
|
egress_policer_details_to_param(details, &policer->app_srtcm_params);
|
2016-03-02 20:35:54 +00:00
|
|
|
err = rte_meter_srtcm_config(&policer->egress_meter,
|
2016-10-04 17:58:05 -07:00
|
|
|
&policer->app_srtcm_params);
|
|
|
|
if (!err) {
|
|
|
|
*conf = &policer->qos_conf;
|
|
|
|
} else {
|
2016-08-09 18:20:26 +01:00
|
|
|
free(policer);
|
2016-10-04 17:58:05 -07:00
|
|
|
*conf = NULL;
|
2016-08-09 18:20:26 +01:00
|
|
|
err = -err;
|
|
|
|
}
|
2016-03-02 20:35:54 +00:00
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-04 17:58:05 -07:00
|
|
|
egress_policer_qos_destruct(struct qos_conf *conf)
|
2016-03-02 20:35:54 +00:00
|
|
|
{
|
|
|
|
struct egress_policer *policer = CONTAINER_OF(conf, struct egress_policer,
|
2016-10-04 17:58:05 -07:00
|
|
|
qos_conf);
|
2016-03-02 20:35:54 +00:00
|
|
|
free(policer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-10-04 17:58:05 -07:00
|
|
|
egress_policer_qos_get(const struct qos_conf *conf, struct smap *details)
|
2016-03-02 20:35:54 +00:00
|
|
|
{
|
2016-10-04 17:58:05 -07:00
|
|
|
struct egress_policer *policer =
|
|
|
|
CONTAINER_OF(conf, struct egress_policer, qos_conf);
|
|
|
|
|
|
|
|
smap_add_format(details, "cir", "%"PRIu64, policer->app_srtcm_params.cir);
|
|
|
|
smap_add_format(details, "cbs", "%"PRIu64, policer->app_srtcm_params.cbs);
|
2016-02-26 15:58:24 -08:00
|
|
|
|
2016-03-02 20:35:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
static bool
|
2017-05-05 11:52:05 +01:00
|
|
|
egress_policer_qos_is_equal(const struct qos_conf *conf,
|
|
|
|
const struct smap *details)
|
2016-03-02 20:35:54 +00:00
|
|
|
{
|
2016-10-04 17:58:05 -07:00
|
|
|
struct egress_policer *policer =
|
|
|
|
CONTAINER_OF(conf, struct egress_policer, qos_conf);
|
|
|
|
struct rte_meter_srtcm_params params;
|
2016-03-02 20:35:54 +00:00
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
egress_policer_details_to_param(details, ¶ms);
|
2016-08-09 18:20:26 +01:00
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
return !memcmp(¶ms, &policer->app_srtcm_params, sizeof params);
|
2016-03-02 20:35:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2017-09-06 22:21:59 -07:00
|
|
|
egress_policer_run(struct qos_conf *conf, struct rte_mbuf **pkts, int pkt_cnt,
|
2018-05-16 19:24:46 -07:00
|
|
|
bool should_steal)
|
2016-03-02 20:35:54 +00:00
|
|
|
{
|
|
|
|
int cnt = 0;
|
2016-10-04 17:58:05 -07:00
|
|
|
struct egress_policer *policer =
|
|
|
|
CONTAINER_OF(conf, struct egress_policer, qos_conf);
|
2016-03-02 20:35:54 +00:00
|
|
|
|
2017-09-06 22:21:59 -07:00
|
|
|
cnt = netdev_dpdk_policer_run(&policer->egress_meter, pkts,
|
2018-05-16 19:24:46 -07:00
|
|
|
pkt_cnt, should_steal);
|
2016-03-02 20:35:54 +00:00
|
|
|
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct dpdk_qos_ops egress_policer_ops = {
|
|
|
|
"egress-policer", /* qos_name */
|
|
|
|
egress_policer_qos_construct,
|
|
|
|
egress_policer_qos_destruct,
|
|
|
|
egress_policer_qos_get,
|
2016-10-04 17:58:05 -07:00
|
|
|
egress_policer_qos_is_equal,
|
2016-03-02 20:35:54 +00:00
|
|
|
egress_policer_run
|
|
|
|
};
|
|
|
|
|
2016-02-26 15:58:24 -08:00
|
|
|
static int
|
|
|
|
netdev_dpdk_reconfigure(struct netdev *netdev)
|
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
|
|
|
|
if (netdev->n_txq == dev->requested_n_txq
|
2016-08-09 17:01:20 +01:00
|
|
|
&& netdev->n_rxq == dev->requested_n_rxq
|
2016-09-30 14:50:53 +01:00
|
|
|
&& dev->mtu == dev->requested_mtu
|
2018-04-23 11:42:41 +00:00
|
|
|
&& dev->lsc_interrupt_mode == dev->requested_lsc_interrupt_mode
|
2016-09-30 14:50:53 +01:00
|
|
|
&& dev->rxq_size == dev->requested_rxq_size
|
2017-01-12 22:18:13 +08:00
|
|
|
&& dev->txq_size == dev->requested_txq_size
|
|
|
|
&& dev->socket_id == dev->requested_socket_id) {
|
2016-02-26 15:58:24 -08:00
|
|
|
/* Reconfiguration is unnecessary */
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
rte_eth_dev_stop(dev->port_id);
|
|
|
|
|
2017-09-01 13:40:25 -07:00
|
|
|
err = netdev_dpdk_mempool_configure(dev);
|
2017-10-19 17:54:03 +01:00
|
|
|
if (err && err != EEXIST) {
|
2017-09-01 13:40:25 -07:00
|
|
|
goto out;
|
2016-08-09 17:01:20 +01:00
|
|
|
}
|
|
|
|
|
2018-04-23 11:42:41 +00:00
|
|
|
dev->lsc_interrupt_mode = dev->requested_lsc_interrupt_mode;
|
|
|
|
|
2016-02-26 15:58:24 -08:00
|
|
|
netdev->n_txq = dev->requested_n_txq;
|
|
|
|
netdev->n_rxq = dev->requested_n_rxq;
|
|
|
|
|
2016-09-30 14:50:53 +01:00
|
|
|
dev->rxq_size = dev->requested_rxq_size;
|
|
|
|
dev->txq_size = dev->requested_txq_size;
|
|
|
|
|
2016-02-26 15:58:24 -08:00
|
|
|
rte_free(dev->tx_q);
|
|
|
|
err = dpdk_eth_dev_init(dev);
|
2016-10-04 17:58:05 -07:00
|
|
|
dev->tx_q = netdev_dpdk_alloc_txq(netdev->n_txq);
|
|
|
|
if (!dev->tx_q) {
|
|
|
|
err = ENOMEM;
|
|
|
|
}
|
2016-02-26 15:58:24 -08:00
|
|
|
|
2016-08-09 17:01:20 +01:00
|
|
|
netdev_change_seq_changed(netdev);
|
|
|
|
|
2016-02-26 15:58:24 -08:00
|
|
|
out:
|
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2016-11-15 15:40:49 -08:00
|
|
|
static int
|
2016-08-19 10:22:30 +01:00
|
|
|
dpdk_vhost_reconfigure_helper(struct netdev_dpdk *dev)
|
|
|
|
OVS_REQUIRES(dev->mutex)
|
2016-02-26 15:58:24 -08:00
|
|
|
{
|
2016-08-19 10:22:30 +01:00
|
|
|
dev->up.n_txq = dev->requested_n_txq;
|
|
|
|
dev->up.n_rxq = dev->requested_n_rxq;
|
2017-03-09 13:57:37 +00:00
|
|
|
int err;
|
2016-02-26 15:58:24 -08:00
|
|
|
|
2016-07-08 16:52:37 +03:00
|
|
|
/* Enable TX queue 0 by default if it wasn't disabled. */
|
|
|
|
if (dev->tx_q[0].map == OVS_VHOST_QUEUE_MAP_UNKNOWN) {
|
|
|
|
dev->tx_q[0].map = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
netdev_dpdk_remap_txqs(dev);
|
|
|
|
|
2017-09-01 13:40:25 -07:00
|
|
|
err = netdev_dpdk_mempool_configure(dev);
|
2017-10-19 17:54:03 +01:00
|
|
|
if (!err) {
|
|
|
|
/* A new mempool was created. */
|
2017-09-01 13:40:25 -07:00
|
|
|
netdev_change_seq_changed(&dev->up);
|
2017-10-19 17:54:03 +01:00
|
|
|
} else if (err != EEXIST){
|
|
|
|
return err;
|
2016-06-13 11:10:09 +01:00
|
|
|
}
|
2016-08-03 13:29:24 +01:00
|
|
|
if (netdev_dpdk_get_vid(dev) >= 0) {
|
2017-08-29 23:12:03 -07:00
|
|
|
if (dev->vhost_reconfigured == false) {
|
|
|
|
dev->vhost_reconfigured = true;
|
|
|
|
/* Carrier status may need updating. */
|
|
|
|
netdev_change_seq_changed(&dev->up);
|
|
|
|
}
|
2016-07-08 16:52:37 +03:00
|
|
|
}
|
2016-11-15 15:40:49 -08:00
|
|
|
|
|
|
|
return 0;
|
2016-08-19 10:22:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netdev_dpdk_vhost_reconfigure(struct netdev *netdev)
|
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2016-11-15 15:40:49 -08:00
|
|
|
int err;
|
2016-08-19 10:22:30 +01:00
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
2016-11-15 15:40:49 -08:00
|
|
|
err = dpdk_vhost_reconfigure_helper(dev);
|
2016-08-19 10:22:30 +01:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
2016-11-15 15:40:49 -08:00
|
|
|
|
|
|
|
return err;
|
2016-08-19 10:22:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netdev_dpdk_vhost_client_reconfigure(struct netdev *netdev)
|
|
|
|
{
|
|
|
|
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
2016-11-15 15:40:49 -08:00
|
|
|
int err;
|
netdev-dpdk: vHost IOMMU support
DPDK v17.11 introduces support for the vHost IOMMU feature.
This is a security feature, which restricts the vhost memory
that a virtio device may access.
This feature also enables the vhost REPLY_ACK protocol, the
implementation of which is known to work in newer versions of
QEMU (i.e. v2.10.0), but is buggy in older versions (v2.7.0 -
v2.9.0, inclusive). As such, the feature is disabled by default
in (and should remain so), for the aforementioned older QEMU
verions. Starting with QEMU v2.9.1, vhost-iommu-support can
safely be enabled, even without having an IOMMU device, with
no performance penalty.
This patch adds a new global config option, vhost-iommu-support,
that controls enablement of the vhost IOMMU feature:
ovs-vsctl set Open_vSwitch . other_config:vhost-iommu-support=true
This value defaults to false; to enable IOMMU support, this field
should be set to true when setting other global parameters on init
(such as "dpdk-socket-mem", for example). Changing the value at
runtime is not supported, and requires restarting the vswitch daemon.
Signed-off-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2017-12-08 10:53:47 +00:00
|
|
|
uint64_t vhost_flags = 0;
|
2018-01-31 10:44:54 +00:00
|
|
|
bool zc_enabled;
|
2016-08-19 10:22:30 +01:00
|
|
|
|
|
|
|
ovs_mutex_lock(&dev->mutex);
|
|
|
|
|
2016-08-15 16:11:26 +01:00
|
|
|
/* Configure vHost client mode if requested and if the following criteria
|
|
|
|
* are met:
|
2016-08-19 10:22:30 +01:00
|
|
|
* 1. Device hasn't been registered yet.
|
|
|
|
* 2. A path has been specified.
|
2016-08-15 16:11:26 +01:00
|
|
|
*/
|
|
|
|
if (!(dev->vhost_driver_flags & RTE_VHOST_USER_CLIENT)
|
2016-08-19 10:22:30 +01:00
|
|
|
&& strlen(dev->vhost_id)) {
|
netdev-dpdk: vHost IOMMU support
DPDK v17.11 introduces support for the vHost IOMMU feature.
This is a security feature, which restricts the vhost memory
that a virtio device may access.
This feature also enables the vhost REPLY_ACK protocol, the
implementation of which is known to work in newer versions of
QEMU (i.e. v2.10.0), but is buggy in older versions (v2.7.0 -
v2.9.0, inclusive). As such, the feature is disabled by default
in (and should remain so), for the aforementioned older QEMU
verions. Starting with QEMU v2.9.1, vhost-iommu-support can
safely be enabled, even without having an IOMMU device, with
no performance penalty.
This patch adds a new global config option, vhost-iommu-support,
that controls enablement of the vhost IOMMU feature:
ovs-vsctl set Open_vSwitch . other_config:vhost-iommu-support=true
This value defaults to false; to enable IOMMU support, this field
should be set to true when setting other global parameters on init
(such as "dpdk-socket-mem", for example). Changing the value at
runtime is not supported, and requires restarting the vswitch daemon.
Signed-off-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2017-12-08 10:53:47 +00:00
|
|
|
/* Register client-mode device. */
|
|
|
|
vhost_flags |= RTE_VHOST_USER_CLIENT;
|
|
|
|
|
|
|
|
/* Enable IOMMU support, if explicitly requested. */
|
|
|
|
if (dpdk_vhost_iommu_enabled()) {
|
|
|
|
vhost_flags |= RTE_VHOST_USER_IOMMU_SUPPORT;
|
|
|
|
}
|
2018-01-31 10:44:54 +00:00
|
|
|
|
|
|
|
zc_enabled = dev->vhost_driver_flags
|
|
|
|
& RTE_VHOST_USER_DEQUEUE_ZERO_COPY;
|
|
|
|
/* Enable zero copy flag, if requested */
|
|
|
|
if (zc_enabled) {
|
|
|
|
vhost_flags |= RTE_VHOST_USER_DEQUEUE_ZERO_COPY;
|
|
|
|
}
|
|
|
|
|
netdev-dpdk: vHost IOMMU support
DPDK v17.11 introduces support for the vHost IOMMU feature.
This is a security feature, which restricts the vhost memory
that a virtio device may access.
This feature also enables the vhost REPLY_ACK protocol, the
implementation of which is known to work in newer versions of
QEMU (i.e. v2.10.0), but is buggy in older versions (v2.7.0 -
v2.9.0, inclusive). As such, the feature is disabled by default
in (and should remain so), for the aforementioned older QEMU
verions. Starting with QEMU v2.9.1, vhost-iommu-support can
safely be enabled, even without having an IOMMU device, with
no performance penalty.
This patch adds a new global config option, vhost-iommu-support,
that controls enablement of the vhost IOMMU feature:
ovs-vsctl set Open_vSwitch . other_config:vhost-iommu-support=true
This value defaults to false; to enable IOMMU support, this field
should be set to true when setting other global parameters on init
(such as "dpdk-socket-mem", for example). Changing the value at
runtime is not supported, and requires restarting the vswitch daemon.
Signed-off-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2017-12-08 10:53:47 +00:00
|
|
|
err = rte_vhost_driver_register(dev->vhost_id, vhost_flags);
|
2016-08-15 16:11:26 +01:00
|
|
|
if (err) {
|
2016-08-19 10:22:30 +01:00
|
|
|
VLOG_ERR("vhost-user device setup failure for device %s\n",
|
|
|
|
dev->vhost_id);
|
2016-11-15 15:40:49 -08:00
|
|
|
goto unlock;
|
2016-08-15 16:11:26 +01:00
|
|
|
} else {
|
2016-08-19 10:22:30 +01:00
|
|
|
/* Configuration successful */
|
netdev-dpdk: vHost IOMMU support
DPDK v17.11 introduces support for the vHost IOMMU feature.
This is a security feature, which restricts the vhost memory
that a virtio device may access.
This feature also enables the vhost REPLY_ACK protocol, the
implementation of which is known to work in newer versions of
QEMU (i.e. v2.10.0), but is buggy in older versions (v2.7.0 -
v2.9.0, inclusive). As such, the feature is disabled by default
in (and should remain so), for the aforementioned older QEMU
verions. Starting with QEMU v2.9.1, vhost-iommu-support can
safely be enabled, even without having an IOMMU device, with
no performance penalty.
This patch adds a new global config option, vhost-iommu-support,
that controls enablement of the vhost IOMMU feature:
ovs-vsctl set Open_vSwitch . other_config:vhost-iommu-support=true
This value defaults to false; to enable IOMMU support, this field
should be set to true when setting other global parameters on init
(such as "dpdk-socket-mem", for example). Changing the value at
runtime is not supported, and requires restarting the vswitch daemon.
Signed-off-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2017-12-08 10:53:47 +00:00
|
|
|
dev->vhost_driver_flags |= vhost_flags;
|
2016-08-19 10:22:30 +01:00
|
|
|
VLOG_INFO("vHost User device '%s' created in 'client' mode, "
|
|
|
|
"using client socket '%s'",
|
|
|
|
dev->up.name, dev->vhost_id);
|
2018-01-31 10:44:54 +00:00
|
|
|
if (zc_enabled) {
|
|
|
|
VLOG_INFO("Zero copy enabled for vHost port %s", dev->up.name);
|
|
|
|
}
|
2016-08-15 16:11:26 +01:00
|
|
|
}
|
2017-08-01 16:14:10 -07:00
|
|
|
|
|
|
|
err = rte_vhost_driver_callback_register(dev->vhost_id,
|
|
|
|
&virtio_net_device_ops);
|
|
|
|
if (err) {
|
|
|
|
VLOG_ERR("rte_vhost_driver_callback_register failed for "
|
|
|
|
"vhost user client port: %s\n", dev->up.name);
|
|
|
|
goto unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = rte_vhost_driver_disable_features(dev->vhost_id,
|
|
|
|
1ULL << VIRTIO_NET_F_HOST_TSO4
|
|
|
|
| 1ULL << VIRTIO_NET_F_HOST_TSO6
|
|
|
|
| 1ULL << VIRTIO_NET_F_CSUM);
|
|
|
|
if (err) {
|
|
|
|
VLOG_ERR("rte_vhost_driver_disable_features failed for vhost user "
|
|
|
|
"client port: %s\n", dev->up.name);
|
|
|
|
goto unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = rte_vhost_driver_start(dev->vhost_id);
|
|
|
|
if (err) {
|
|
|
|
VLOG_ERR("rte_vhost_driver_start failed for vhost user "
|
|
|
|
"client port: %s\n", dev->up.name);
|
|
|
|
goto unlock;
|
|
|
|
}
|
2016-08-15 16:11:26 +01:00
|
|
|
}
|
|
|
|
|
2016-11-15 15:40:49 -08:00
|
|
|
err = dpdk_vhost_reconfigure_helper(dev);
|
|
|
|
|
|
|
|
unlock:
|
2016-02-26 15:58:24 -08:00
|
|
|
ovs_mutex_unlock(&dev->mutex);
|
|
|
|
|
2016-11-15 15:40:49 -08:00
|
|
|
return err;
|
2016-02-26 15:58:24 -08:00
|
|
|
}
|
|
|
|
|
2016-10-04 17:58:05 -07:00
|
|
|
#define NETDEV_DPDK_CLASS(NAME, INIT, CONSTRUCT, DESTRUCT, \
|
2016-07-08 16:52:37 +03:00
|
|
|
SET_CONFIG, SET_TX_MULTIQ, SEND, \
|
2018-01-09 07:55:37 +00:00
|
|
|
GET_CARRIER, GET_STATS, \
|
|
|
|
GET_CUSTOM_STATS, \
|
2016-07-08 16:52:37 +03:00
|
|
|
GET_FEATURES, GET_STATUS, \
|
|
|
|
RECONFIGURE, RXQ_RECV) \
|
2014-07-11 13:37:11 +01:00
|
|
|
{ \
|
|
|
|
NAME, \
|
2016-03-14 18:18:11 +03:00
|
|
|
true, /* is_pmd */ \
|
2016-10-04 17:58:05 -07:00
|
|
|
INIT, /* init */ \
|
2014-07-11 13:37:11 +01:00
|
|
|
NULL, /* netdev_dpdk_run */ \
|
|
|
|
NULL, /* netdev_dpdk_wait */ \
|
|
|
|
\
|
|
|
|
netdev_dpdk_alloc, \
|
|
|
|
CONSTRUCT, \
|
2015-03-05 13:42:04 -08:00
|
|
|
DESTRUCT, \
|
2014-07-11 13:37:11 +01:00
|
|
|
netdev_dpdk_dealloc, \
|
|
|
|
netdev_dpdk_get_config, \
|
2016-07-08 16:52:37 +03:00
|
|
|
SET_CONFIG, \
|
2014-07-11 13:37:11 +01:00
|
|
|
NULL, /* get_tunnel_config */ \
|
2015-03-05 13:42:04 -08:00
|
|
|
NULL, /* build header */ \
|
|
|
|
NULL, /* push header */ \
|
|
|
|
NULL, /* pop header */ \
|
2014-06-11 16:33:08 -07:00
|
|
|
netdev_dpdk_get_numa_id, /* get_numa_id */ \
|
2016-07-08 16:52:37 +03:00
|
|
|
SET_TX_MULTIQ, \
|
2014-07-11 13:37:11 +01:00
|
|
|
\
|
2014-10-14 19:01:49 +02:00
|
|
|
SEND, /* send */ \
|
2014-07-11 13:37:11 +01:00
|
|
|
NULL, /* send_wait */ \
|
|
|
|
\
|
|
|
|
netdev_dpdk_set_etheraddr, \
|
|
|
|
netdev_dpdk_get_etheraddr, \
|
|
|
|
netdev_dpdk_get_mtu, \
|
2016-08-09 17:01:20 +01:00
|
|
|
netdev_dpdk_set_mtu, \
|
2014-07-11 13:37:11 +01:00
|
|
|
netdev_dpdk_get_ifindex, \
|
2015-03-05 13:42:04 -08:00
|
|
|
GET_CARRIER, \
|
2014-07-11 13:37:11 +01:00
|
|
|
netdev_dpdk_get_carrier_resets, \
|
|
|
|
netdev_dpdk_set_miimon, \
|
2015-03-05 13:42:04 -08:00
|
|
|
GET_STATS, \
|
2018-01-09 07:55:37 +00:00
|
|
|
GET_CUSTOM_STATS, \
|
2015-03-05 13:42:04 -08:00
|
|
|
GET_FEATURES, \
|
2014-07-11 13:37:11 +01:00
|
|
|
NULL, /* set_advertisements */ \
|
2017-06-23 16:47:59 +00:00
|
|
|
NULL, /* get_pt_mode */ \
|
2014-07-11 13:37:11 +01:00
|
|
|
\
|
2016-05-24 17:36:51 +01:00
|
|
|
netdev_dpdk_set_policing, \
|
2016-03-02 20:35:54 +00:00
|
|
|
netdev_dpdk_get_qos_types, \
|
2014-07-11 13:37:11 +01:00
|
|
|
NULL, /* get_qos_capabilities */ \
|
2016-03-02 20:35:54 +00:00
|
|
|
netdev_dpdk_get_qos, \
|
|
|
|
netdev_dpdk_set_qos, \
|
2014-07-11 13:37:11 +01:00
|
|
|
NULL, /* get_queue */ \
|
|
|
|
NULL, /* set_queue */ \
|
|
|
|
NULL, /* delete_queue */ \
|
|
|
|
NULL, /* get_queue_stats */ \
|
|
|
|
NULL, /* queue_dump_start */ \
|
|
|
|
NULL, /* queue_dump_next */ \
|
|
|
|
NULL, /* queue_dump_done */ \
|
|
|
|
NULL, /* dump_queue_stats */ \
|
|
|
|
\
|
|
|
|
NULL, /* set_in4 */ \
|
2016-03-24 09:30:57 -07:00
|
|
|
NULL, /* get_addr_list */ \
|
2014-07-11 13:37:11 +01:00
|
|
|
NULL, /* add_router */ \
|
|
|
|
NULL, /* get_next_hop */ \
|
2015-03-05 13:42:04 -08:00
|
|
|
GET_STATUS, \
|
2014-07-11 13:37:11 +01:00
|
|
|
NULL, /* arp_lookup */ \
|
|
|
|
\
|
|
|
|
netdev_dpdk_update_flags, \
|
2016-02-26 15:58:24 -08:00
|
|
|
RECONFIGURE, \
|
2014-07-11 13:37:11 +01:00
|
|
|
\
|
|
|
|
netdev_dpdk_rxq_alloc, \
|
|
|
|
netdev_dpdk_rxq_construct, \
|
|
|
|
netdev_dpdk_rxq_destruct, \
|
|
|
|
netdev_dpdk_rxq_dealloc, \
|
2015-03-05 13:42:04 -08:00
|
|
|
RXQ_RECV, \
|
2014-07-11 13:37:11 +01:00
|
|
|
NULL, /* rx_wait */ \
|
|
|
|
NULL, /* rxq_drain */ \
|
2017-06-13 18:03:28 +03:00
|
|
|
NO_OFFLOAD_API \
|
2014-07-11 13:37:11 +01:00
|
|
|
}
|
2014-03-24 19:23:08 -07:00
|
|
|
|
2015-05-18 08:49:24 -07:00
|
|
|
static const struct netdev_class dpdk_class =
|
2014-07-11 13:37:11 +01:00
|
|
|
NETDEV_DPDK_CLASS(
|
|
|
|
"dpdk",
|
2016-10-04 17:58:05 -07:00
|
|
|
netdev_dpdk_class_init,
|
2014-09-08 14:52:54 -07:00
|
|
|
netdev_dpdk_construct,
|
2015-03-05 13:42:04 -08:00
|
|
|
netdev_dpdk_destruct,
|
2016-07-08 16:52:37 +03:00
|
|
|
netdev_dpdk_set_config,
|
|
|
|
netdev_dpdk_set_tx_multiq,
|
2015-03-05 13:42:04 -08:00
|
|
|
netdev_dpdk_eth_send,
|
|
|
|
netdev_dpdk_get_carrier,
|
|
|
|
netdev_dpdk_get_stats,
|
2018-01-09 07:55:37 +00:00
|
|
|
netdev_dpdk_get_custom_stats,
|
2015-03-05 13:42:04 -08:00
|
|
|
netdev_dpdk_get_features,
|
|
|
|
netdev_dpdk_get_status,
|
2016-02-26 15:58:24 -08:00
|
|
|
netdev_dpdk_reconfigure,
|
2015-03-05 13:42:04 -08:00
|
|
|
netdev_dpdk_rxq_recv);
|
2014-07-11 13:37:11 +01:00
|
|
|
|
2015-05-18 08:49:24 -07:00
|
|
|
static const struct netdev_class dpdk_ring_class =
|
2014-07-11 13:37:11 +01:00
|
|
|
NETDEV_DPDK_CLASS(
|
|
|
|
"dpdkr",
|
2016-10-04 17:58:05 -07:00
|
|
|
netdev_dpdk_class_init,
|
2014-09-08 14:52:54 -07:00
|
|
|
netdev_dpdk_ring_construct,
|
2015-03-05 13:42:04 -08:00
|
|
|
netdev_dpdk_destruct,
|
2016-08-15 10:36:19 +01:00
|
|
|
netdev_dpdk_ring_set_config,
|
2016-07-08 16:52:37 +03:00
|
|
|
netdev_dpdk_set_tx_multiq,
|
2015-03-05 13:42:04 -08:00
|
|
|
netdev_dpdk_ring_send,
|
|
|
|
netdev_dpdk_get_carrier,
|
|
|
|
netdev_dpdk_get_stats,
|
2018-01-09 07:55:37 +00:00
|
|
|
netdev_dpdk_get_custom_stats,
|
2015-03-05 13:42:04 -08:00
|
|
|
netdev_dpdk_get_features,
|
|
|
|
netdev_dpdk_get_status,
|
2016-02-26 15:58:24 -08:00
|
|
|
netdev_dpdk_reconfigure,
|
2015-03-05 13:42:04 -08:00
|
|
|
netdev_dpdk_rxq_recv);
|
|
|
|
|
2016-08-15 16:11:25 +01:00
|
|
|
static const struct netdev_class dpdk_vhost_class =
|
2015-06-04 06:51:40 -07:00
|
|
|
NETDEV_DPDK_CLASS(
|
|
|
|
"dpdkvhostuser",
|
2017-08-01 16:14:10 -07:00
|
|
|
NULL,
|
2016-08-15 16:11:25 +01:00
|
|
|
netdev_dpdk_vhost_construct,
|
2015-03-05 13:42:04 -08:00
|
|
|
netdev_dpdk_vhost_destruct,
|
2016-08-19 10:22:30 +01:00
|
|
|
NULL,
|
2016-07-08 16:52:37 +03:00
|
|
|
NULL,
|
2015-03-05 13:42:04 -08:00
|
|
|
netdev_dpdk_vhost_send,
|
|
|
|
netdev_dpdk_vhost_get_carrier,
|
|
|
|
netdev_dpdk_vhost_get_stats,
|
|
|
|
NULL,
|
2014-10-14 19:01:49 +02:00
|
|
|
NULL,
|
2018-01-16 02:22:16 -02:00
|
|
|
netdev_dpdk_vhost_user_get_status,
|
2016-08-15 16:11:25 +01:00
|
|
|
netdev_dpdk_vhost_reconfigure,
|
2015-03-05 13:42:04 -08:00
|
|
|
netdev_dpdk_vhost_rxq_recv);
|
2016-08-19 10:22:30 +01:00
|
|
|
static const struct netdev_class dpdk_vhost_client_class =
|
|
|
|
NETDEV_DPDK_CLASS(
|
|
|
|
"dpdkvhostuserclient",
|
2017-08-01 16:14:10 -07:00
|
|
|
NULL,
|
2016-08-19 10:22:30 +01:00
|
|
|
netdev_dpdk_vhost_client_construct,
|
|
|
|
netdev_dpdk_vhost_destruct,
|
|
|
|
netdev_dpdk_vhost_client_set_config,
|
|
|
|
NULL,
|
|
|
|
netdev_dpdk_vhost_send,
|
|
|
|
netdev_dpdk_vhost_get_carrier,
|
|
|
|
netdev_dpdk_vhost_get_stats,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2018-01-16 02:22:16 -02:00
|
|
|
netdev_dpdk_vhost_user_get_status,
|
2016-08-19 10:22:30 +01:00
|
|
|
netdev_dpdk_vhost_client_reconfigure,
|
|
|
|
netdev_dpdk_vhost_rxq_recv);
|
2014-07-11 13:37:11 +01:00
|
|
|
|
2014-03-24 19:23:08 -07:00
|
|
|
void
|
|
|
|
netdev_dpdk_register(void)
|
|
|
|
{
|
2016-04-29 13:44:01 -04:00
|
|
|
netdev_register_provider(&dpdk_class);
|
|
|
|
netdev_register_provider(&dpdk_ring_class);
|
2016-08-15 16:11:25 +01:00
|
|
|
netdev_register_provider(&dpdk_vhost_class);
|
2016-08-19 10:22:30 +01:00
|
|
|
netdev_register_provider(&dpdk_vhost_client_class);
|
2014-03-24 19:23:08 -07:00
|
|
|
}
|