From patchwork Thu Sep 29 10:27:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Kavanagh X-Patchwork-Id: 676587 X-Patchwork-Delegate: diproiettod@vmware.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3sl9k42g8fz9s5w for ; Thu, 29 Sep 2016 20:27:24 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 908361066D; Thu, 29 Sep 2016 03:27:11 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 5C88710658 for ; Thu, 29 Sep 2016 03:27:09 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id E18081E03F3 for ; Thu, 29 Sep 2016 04:27:08 -0600 (MDT) X-ASG-Debug-ID: 1475144828-09eadd06bee45c0001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar5.cudamail.com with ESMTP id exiLytONaTM4fymO (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 29 Sep 2016 04:27:08 -0600 (MDT) X-Barracuda-Envelope-From: mark.b.kavanagh@intel.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO mga09.intel.com) (134.134.136.24) by mx1-pf1.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 29 Sep 2016 10:27:08 -0000 Received-SPF: pass (mx1-pf1.cudamail.com: SPF record at intel.com designates 134.134.136.24 as permitted sender) X-Barracuda-Apparent-Source-IP: 134.134.136.24 X-Barracuda-RBL-IP: 134.134.136.24 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP; 29 Sep 2016 03:27:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,414,1470726000"; d="scan'208";a="174506994" Received: from silpixa00380299.ir.intel.com ([10.237.222.17]) by fmsmga004.fm.intel.com with ESMTP; 29 Sep 2016 03:27:07 -0700 X-CudaMail-Envelope-Sender: mark.b.kavanagh@intel.com From: Mark Kavanagh To: dev@openvswitch.org X-CudaMail-MID: CM-E1-928004869 X-CudaMail-DTE: 092916 X-CudaMail-Originating-IP: 134.134.136.24 Date: Thu, 29 Sep 2016 11:27:03 +0100 X-ASG-Orig-Subj: [##CM-E1-928004869##][ovs-dev][PATCH 2/2] netdev-dpdk: Fix coding style Message-Id: <1475144823-209138-3-git-send-email-mark.b.kavanagh@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1475144823-209138-1-git-send-email-mark.b.kavanagh@intel.com> References: <1475144823-209138-1-git-send-email-mark.b.kavanagh@intel.com> X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1475144828 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-ASG-Whitelist: EmailCat (corporate) Subject: [ovs-dev] [PATCH 2/2] netdev-dpdk: Fix coding style X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" Coding style violations of the following conventions are present in netdev-dpdk.c: - limit lines to 79 characters - put a space after (but not before) the "sizeof" keyword. - put a space between the () used in a cast and the expression whose type is cast: (void *) 0. Resolve occurrences of each, and any other minor style infractions. Signed-off-by: Mark Kavanagh --- lib/netdev-dpdk.c | 81 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 819a842..dbf72ed 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -76,12 +76,14 @@ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); * The minimum mbuf size is limited to avoid scatter behaviour and drop in * performance for standard Ethernet MTU. */ -#define ETHER_HDR_MAX_LEN (ETHER_HDR_LEN + ETHER_CRC_LEN + (2 * VLAN_HEADER_LEN)) +#define ETHER_HDR_MAX_LEN (ETHER_HDR_LEN + ETHER_CRC_LEN \ + + (2 * VLAN_HEADER_LEN)) #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) -#define FRAME_LEN_TO_MTU(frame_len) ((frame_len)- ETHER_HDR_LEN - ETHER_CRC_LEN) -#define MBUF_SIZE(mtu) ( MTU_TO_MAX_FRAME_LEN(mtu) \ - + sizeof(struct dp_packet) \ +#define FRAME_LEN_TO_MTU(frame_len) ((frame_len) \ + - ETHER_HDR_LEN - ETHER_CRC_LEN) +#define MBUF_SIZE(mtu) ( MTU_TO_MAX_FRAME_LEN(mtu) \ + + sizeof (struct dp_packet) \ + RTE_PKTMBUF_HEADROOM) #define NETDEV_DPDK_MBUF_ALIGN 1024 #define NETDEV_DPDK_MAX_PKT_LEN 9728 @@ -132,8 +134,10 @@ BUILD_ASSERT_DECL((MAX_NB_MBUF / ROUND_DOWN_POW2(MAX_NB_MBUF/MIN_NB_MBUF)) #define SOCKET0 0 -#define NIC_PORT_RX_Q_SIZE 2048 /* Size of Physical NIC RX Queue, Max (n+32<=4096)*/ -#define NIC_PORT_TX_Q_SIZE 2048 /* Size of Physical NIC TX Queue, Max (n+32<=4096)*/ +/* Size of Physical NIC RX Queue, Max (n + 32 <= 4096) */ +#define NIC_PORT_RX_Q_SIZE 2048 +/* Size of Physical NIC TX Queue, Max (n + 32 <= 4096) */ +#define NIC_PORT_TX_Q_SIZE 2048 #define OVS_VHOST_MAX_QUEUE_NUM 1024 /* Maximum number of vHost TX queues. */ #define OVS_VHOST_QUEUE_MAP_UNKNOWN (-1) /* Mapping not initialized. */ @@ -414,8 +418,8 @@ is_dpdk_class(const struct netdev_class *class) * 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 - * behaviour, which reduces performance. To prevent this, use a buffer size that - * is closest to 'mtu', but which satisfies the aforementioned criteria. + * behaviour, which reduces performance. To prevent this, use a buffer size + * that is closest to 'mtu', but which satisfies the aforementioned criteria. */ static uint32_t dpdk_buf_size(int mtu) @@ -481,13 +485,13 @@ dpdk_mp_get(int socket_id, int mtu) OVS_REQUIRES(dpdk_mutex) dmp->socket_id = socket_id; dmp->mtu = mtu; dmp->refcount = 1; - mbp_priv.mbuf_data_room_size = MBUF_SIZE(mtu) - sizeof(struct dp_packet); + mbp_priv.mbuf_data_room_size = MBUF_SIZE(mtu) - sizeof (struct dp_packet); mbp_priv.mbuf_priv_size = sizeof (struct dp_packet) - sizeof (struct rte_mbuf); /* XXX: this is a really rough method of provisioning memory. * It's impossible to determine what the exact memory requirements are when - * the number of ports and rxqs that utilize a particular mempool can change - * dynamically at runtime. For the moment, use this rough heurisitic. + * when the number of ports and rxqs that utilize a particular mempool can + * change dynamically at runtime. For now, use this rough heurisitic. */ if (mtu >= ETHER_MTU) { mp_size = MAX_NB_MBUF; @@ -582,7 +586,7 @@ check_link_status(struct netdev_dpdk *dev) dev->link = link; if (dev->link.link_status) { VLOG_DBG_RL(&rl, "Port %d Link Up - speed %u Mbps - %s", - dev->port_id, (unsigned)dev->link.link_speed, + dev->port_id, (unsigned) dev->link.link_speed, (dev->link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex")); } else { @@ -730,7 +734,7 @@ dpdk_eth_dev_init(struct netdev_dpdk *dev) OVS_REQUIRES(dpdk_mutex) rte_eth_promiscuous_enable(dev->port_id); rte_eth_allmulticast_enable(dev->port_id); - memset(ð_addr, 0x0, sizeof(eth_addr)); + memset(ð_addr, 0x0, sizeof (eth_addr)); rte_eth_macaddr_get(dev->port_id, ð_addr); VLOG_INFO_RL(&rl, "Port %d: "ETH_ADDR_FMT"", dev->port_id, ETH_ADDR_BYTES_ARGS(eth_addr.addr_bytes)); @@ -1007,8 +1011,8 @@ netdev_dpdk_vhost_destruct(struct netdev *netdev) && !(dev->vhost_driver_flags & RTE_VHOST_USER_CLIENT)) { VLOG_ERR("Removing port '%s' while vhost device still attached.", netdev->name); - VLOG_ERR("To restore connectivity after re-adding of port, VM on socket" - " '%s' must be restarted.", dev->vhost_id); + VLOG_ERR("To restore connectivity after re-adding of port, VM on " + "socket '%s' must be restarted.", dev->vhost_id); } free(ovsrcu_get_protected(struct ingress_policer *, @@ -1233,7 +1237,7 @@ 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); + 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; @@ -1407,7 +1411,7 @@ netdev_dpdk_rxq_recv(struct netdev_rxq *rxq, struct dp_packet_batch *batch) if (policer) { dropped = nb_rx; nb_rx = ingress_policer_run(policer, - (struct rte_mbuf **)batch->packets, + (struct rte_mbuf **) batch->packets, nb_rx); dropped -= nb_rx; } @@ -1572,7 +1576,7 @@ dpdk_do_tx_copy(struct netdev *netdev, int qid, struct dp_packet_batch *batch) if (OVS_UNLIKELY(size > dev->max_packet_len)) { VLOG_WARN_RL(&rl, "Too big size %d max_packet_len %d", - (int)size , dev->max_packet_len); + (int) size , dev->max_packet_len); dropped++; continue; @@ -1978,7 +1982,7 @@ netdev_dpdk_policer_construct(uint32_t rate, uint32_t burst) policer->app_srtcm_params.ebs = 0; err = rte_meter_srtcm_config(&policer->in_policer, &policer->app_srtcm_params); - if(err) { + if (err) { VLOG_ERR("Could not create rte meter for ingress policer"); return NULL; } @@ -2142,7 +2146,7 @@ netdev_dpdk_update_flags__(struct netdev_dpdk *dev, /* Clear statistics if device is getting up. */ if (NETDEV_UP & on) { rte_spinlock_lock(&dev->stats_lock); - memset(&dev->stats, 0, sizeof(dev->stats)); + memset(&dev->stats, 0, sizeof (dev->stats)); rte_spinlock_unlock(&dev->stats_lock); } } @@ -2181,14 +2185,16 @@ netdev_dpdk_get_status(const struct netdev *netdev, struct smap *args) ovs_mutex_unlock(&dev->mutex); smap_add_format(args, "port_no", "%d", dev->port_id); - smap_add_format(args, "numa_id", "%d", rte_eth_dev_socket_id(dev->port_id)); + smap_add_format(args, "numa_id", "%d", + rte_eth_dev_socket_id(dev->port_id)); smap_add_format(args, "driver_name", "%s", dev_info.driver_name); smap_add_format(args, "min_rx_bufsize", "%u", dev_info.min_rx_bufsize); smap_add_format(args, "max_rx_pktlen", "%u", dev->max_packet_len); 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); - smap_add_format(args, "max_hash_mac_addrs", "%u", dev_info.max_hash_mac_addrs); + smap_add_format(args, "max_hash_mac_addrs", "%u", + dev_info.max_hash_mac_addrs); smap_add_format(args, "max_vfs", "%u", dev_info.max_vfs); smap_add_format(args, "max_vmdq_pools", "%u", dev_info.max_vmdq_pools); @@ -2327,7 +2333,7 @@ new_device(int vid) int newnode = 0; char ifname[IF_NAME_SZ]; - rte_vhost_get_ifname(vid, ifname, sizeof(ifname)); + rte_vhost_get_ifname(vid, ifname, sizeof (ifname)); ovs_mutex_lock(&dpdk_mutex); /* Add device to the vhost port with the same name as that passed down. */ @@ -2408,7 +2414,7 @@ destroy_device(int vid) bool exists = false; char ifname[IF_NAME_SZ]; - rte_vhost_get_ifname(vid, ifname, sizeof(ifname)); + rte_vhost_get_ifname(vid, ifname, sizeof (ifname)); ovs_mutex_lock(&dpdk_mutex); LIST_FOR_EACH (dev, list_node, &dpdk_list) { @@ -2453,7 +2459,7 @@ vring_state_changed(int vid, uint16_t queue_id, int enable) int qid = queue_id / VIRTIO_QNUM; char ifname[IF_NAME_SZ]; - rte_vhost_get_ifname(vid, ifname, sizeof(ifname)); + rte_vhost_get_ifname(vid, ifname, sizeof (ifname)); if (queue_id % VIRTIO_QNUM == VIRTIO_TXQ) { return 0; @@ -2559,7 +2565,7 @@ dpdk_ring_create(const char dev_name[], unsigned int port_no, } /* XXX: Add support for multiquque ring. */ - err = snprintf(ring_name, sizeof(ring_name), "%s_tx", dev_name); + err = snprintf(ring_name, sizeof (ring_name), "%s_tx", dev_name); if (err < 0) { return -err; } @@ -2572,7 +2578,7 @@ dpdk_ring_create(const char dev_name[], unsigned int port_no, return ENOMEM; } - err = snprintf(ring_name, sizeof(ring_name), "%s_rx", dev_name); + err = snprintf(ring_name, sizeof (ring_name), "%s_rx", dev_name); if (err < 0) { return -err; } @@ -2615,11 +2621,12 @@ dpdk_ring_open(const char dev_name[], unsigned int *eth_port_id) return err; } - /* look through our list to find the device */ + /* Look through our list to find the device */ LIST_FOR_EACH (ivshmem, list_node, &dpdk_ring_list) { if (ivshmem->user_port_id == port_no) { VLOG_INFO("Found dpdk ring device %s:", dev_name); - *eth_port_id = ivshmem->eth_port_id; /* really all that is needed */ + /* Really all that is needed */ + *eth_port_id = ivshmem->eth_port_id; return 0; } } @@ -2635,10 +2642,10 @@ netdev_dpdk_ring_send(struct netdev *netdev, int qid, struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); unsigned i; - /* 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. */ + /* 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. */ for (i = 0; i < batch->count; i++) { dp_packet_rss_invalidate(batch->packets[i]); } @@ -2743,7 +2750,7 @@ netdev_dpdk_get_qos(const struct netdev *netdev, int error = 0; ovs_mutex_lock(&dev->mutex); - if(dev->qos_conf) { + if (dev->qos_conf) { *typep = dev->qos_conf->ops->qos_name; error = (dev->qos_conf->ops->qos_get ? dev->qos_conf->ops->qos_get(netdev, details): 0); @@ -3138,7 +3145,7 @@ process_vhost_flags(char *flag, char *default_val, int size, static char ** grow_argv(char ***argv, size_t cur_siz, size_t grow_by) { - return xrealloc(*argv, sizeof(char *) * (cur_siz + grow_by)); + return xrealloc(*argv, sizeof (char *) * (cur_siz + grow_by)); } static void @@ -3399,7 +3406,7 @@ dpdk_init__(const struct smap *ovs_other_config) int i; /* Get the main thread affinity */ CPU_ZERO(&cpuset); - err = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), + err = pthread_getaffinity_np(pthread_self(), sizeof (cpu_set_t), &cpuset); if (!err) { for (i = 0; i < CPU_SETSIZE; i++) { @@ -3446,7 +3453,7 @@ dpdk_init__(const struct smap *ovs_other_config) /* Set the main thread affinity back to pre rte_eal_init() value */ if (auto_determine && !err) { - err = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), + err = pthread_setaffinity_np(pthread_self(), sizeof (cpu_set_t), &cpuset); if (err) { VLOG_ERR("Thread setaffinity error %d", err);