From patchwork Tue Aug 1 16:54:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrien Mazarguil X-Patchwork-Id: 27344 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 1F9D6A20A; Tue, 1 Aug 2017 18:56:00 +0200 (CEST) Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by dpdk.org (Postfix) with ESMTP id EF509A146 for ; Tue, 1 Aug 2017 18:55:31 +0200 (CEST) Received: by mail-wm0-f49.google.com with SMTP id t138so34938015wmt.1 for ; Tue, 01 Aug 2017 09:55:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=Bz7QsOes7Y9///mCh6ON+eDqqxVZbmn00DHdo7sDvx0=; b=ASWK6IZDPEWMU9yOQC6qnmJfZ05JxH3mD50WtGfVEJNU2142g6u42mmcIA2AuRzCzn Kkusb6JBbSif1OY69fZ0yLcWYEgW5ulG1F/YxSqeqHM1DMUNJZqQYx23+21LQunRSkxL nNvnqdfAK/LCGUMZAB9EsS/WHBo1OggxSZI93e50IBhSMhUfDBinKwx1B+L3+tJwA0xS rRd8A5foJhEao95hIk0vUXWdFM1zR4y53YNf1qqEWUyfEcra/46ZbxxMthKkRinIgACU JPXXKoDUnrjKoHHPIYBnCDoj1XFzw9OfK8dbp9THlnL7jdSHY4qxh4Y6bMeIe907cxnw +sNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Bz7QsOes7Y9///mCh6ON+eDqqxVZbmn00DHdo7sDvx0=; b=CQDC85HOKML9GbZ8/zUZ+yH1lhAz4mIDpEP8TH6X7gwBqZLuvpjn0uzEJfkSEuZoA7 /cmBjS3hYbd+spafGgZhG2Cyors2OblkTa+M6dGo9SiWIWewvpt+Q8mQPOE5VRWwueiA knBfNfHI7uBAeNy8nSmJpJIf0bkRENtLMIUDWWt6co0Ajf3iqxUl145vJ4Wfwo7wRR3z 5TVtTd5BTq2H317dYRrMWkpdQigAnsac2I0KDzJ7kGdN7MTj5aNPKJY3PzYGG1+S/Ztf xhVLMP/QT4I+ntelrgxXlKm2pgua3scrHefrnlFLLE5+DeeGGRMc7nALOc5CQ42rCKsG lA8w== X-Gm-Message-State: AIVw1138yjpizrHGWNzCgZMsKPEG1t7XpWGKo/7tUfYlSIMc2ECVBebJ XALd0KtaawzeNOgFau8= X-Received: by 10.28.174.7 with SMTP id x7mr1918319wme.43.1501606531184; Tue, 01 Aug 2017 09:55:31 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id i7sm29395444wrb.19.2017.08.01.09.55.30 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 01 Aug 2017 09:55:30 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Date: Tue, 1 Aug 2017 18:54:15 +0200 Message-Id: <550a9cff6da171ae5a84aee870ed0243a999dc93.1501598384.git.adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v1 28/48] net/mlx4: clean up coding style inconsistencies X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This addresses badly formatted comments and needless empty lines before refactoring functions into different files. Signed-off-by: Adrien Mazarguil --- drivers/net/mlx4/mlx4.c | 89 ++++++++++++++++----------------------- drivers/net/mlx4/mlx4_flow.c | 1 - 2 files changed, 36 insertions(+), 54 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 8cfeab2..8f3377c 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -619,8 +619,10 @@ txq_alloc_elts(struct txq *txq, unsigned int elts_n) txq->elts_head = 0; txq->elts_tail = 0; txq->elts_comp = 0; - /* Request send completion every MLX4_PMD_TX_PER_COMP_REQ packets or - * at least 4 times per ring. */ + /* + * Request send completion every MLX4_PMD_TX_PER_COMP_REQ packets or + * at least 4 times per ring. + */ txq->elts_comp_cd_init = ((MLX4_PMD_TX_PER_COMP_REQ < (elts_n / 4)) ? MLX4_PMD_TX_PER_COMP_REQ : (elts_n / 4)); @@ -629,7 +631,6 @@ txq_alloc_elts(struct txq *txq, unsigned int elts_n) return 0; error: rte_free(elts); - DEBUG("%p: failed, freed everything", (void *)txq); assert(ret > 0); rte_errno = ret; @@ -675,7 +676,6 @@ txq_free_elts(struct txq *txq) rte_free(elts); } - /** * Clean up a TX queue. * @@ -766,7 +766,6 @@ static void mlx4_check_mempool_cb(struct rte_mempool *mp, (void)mp; (void)mem_idx; - /* It already failed, skip the next chunks. */ if (data->ret != 0) return; @@ -810,7 +809,6 @@ static int mlx4_check_mempool(struct rte_mempool *mp, uintptr_t *start, rte_mempool_mem_iter(mp, mlx4_check_mempool_cb, &data); *start = (uintptr_t)data.start; *end = (uintptr_t)data.end; - return data.ret; } @@ -844,7 +842,6 @@ mlx4_mp2mr(struct ibv_pd *pd, struct rte_mempool *mp) (void *)mp); return NULL; } - DEBUG("mempool %p area start=%p end=%p size=%zu", (void *)mp, (void *)start, (void *)end, (size_t)(end - start)); @@ -971,8 +968,10 @@ txq_mp2mr_mbuf_check(struct rte_mempool *mp, void *arg, void *obj, struct txq_mp2mr_mbuf_check_data *data = arg; struct rte_mbuf *buf = obj; - /* Check whether mbuf structure fits element size and whether mempool - * pointer is valid. */ + /* + * Check whether mbuf structure fits element size and whether mempool + * pointer is valid. + */ if (sizeof(*buf) > mp->elt_size || buf->pool != mp) data->ret = -1; } @@ -1235,8 +1234,10 @@ txq_setup(struct rte_eth_dev *dev, struct txq *txq, uint16_t desc, .max_inline_data = MLX4_PMD_MAX_INLINE, }, .qp_type = IBV_QPT_RAW_PACKET, - /* Do *NOT* enable this, completions events are managed per - * TX burst. */ + /* + * Do *NOT* enable this, completions events are managed per + * TX burst. + */ .sq_sig_all = 0, }; tmpl.qp = ibv_create_qp(priv->pd, &attr.init); @@ -1449,9 +1450,11 @@ rxq_alloc_elts(struct rxq *rxq, unsigned int elts_n, struct rte_mbuf **pool) ERROR("%p: empty mbuf pool", (void *)rxq); goto error; } - /* Configure WR. Work request ID contains its own index in + /* + * Configure WR. Work request ID contains its own index in * the elts array and the offset between SGE buffer header and - * its data. */ + * its data. + */ WR_ID(wr->wr_id).id = i; WR_ID(wr->wr_id).offset = (((uintptr_t)buf->buf_addr + RTE_PKTMBUF_HEADROOM) - @@ -1473,8 +1476,10 @@ rxq_alloc_elts(struct rxq *rxq, unsigned int elts_n, struct rte_mbuf **pool) sge->lkey = rxq->mr->lkey; /* Redundant check for tailroom. */ assert(sge->length == rte_pktmbuf_tailroom(buf)); - /* Make sure elts index and SGE mbuf pointer can be deduced - * from WR ID. */ + /* + * Make sure elts index and SGE mbuf pointer can be deduced + * from WR ID. + */ if ((WR_ID(wr->wr_id).id != i) || ((void *)((uintptr_t)sge->addr - WR_ID(wr->wr_id).offset) != buf)) { @@ -1762,7 +1767,6 @@ mlx4_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) ++rxq->priv->dev->data->rx_mbuf_alloc_failed; goto repost; } - /* Reconfigure sge to use rep instead of seg. */ elt->sge.addr = (uintptr_t)rep->buf_addr + RTE_PKTMBUF_HEADROOM; assert(elt->sge.lkey == rxq->mr->lkey); @@ -1770,7 +1774,6 @@ mlx4_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) (((uintptr_t)rep->buf_addr + RTE_PKTMBUF_HEADROOM) - (uintptr_t)rep); assert(WR_ID(wr->wr_id).id == WR_ID(wr_id).id); - /* Update seg information. */ SET_DATA_OFF(seg, RTE_PKTMBUF_HEADROOM); NB_SEGS(seg) = 1; @@ -1780,7 +1783,6 @@ mlx4_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) DATA_LEN(seg) = len; seg->packet_type = 0; seg->ol_flags = 0; - /* Return packet. */ *(pkts++) = seg; ++pkts_ret; @@ -2282,9 +2284,11 @@ mlx4_dev_close(struct rte_eth_dev *dev) (void *)dev, ((priv->ctx != NULL) ? priv->ctx->device->name : "")); priv_mac_addr_del(priv); - /* Prevent crashes when queues are still in use. This is unfortunately + /* + * Prevent crashes when queues are still in use. This is unfortunately * still required for DPDK 1.3 because some programs (such as testpmd) - * never release them before closing the device. */ + * never release them before closing the device. + */ dev->rx_pkt_burst = removed_rx_burst; dev->tx_pkt_burst = removed_tx_burst; if (priv->rxqs != NULL) { @@ -2401,6 +2405,7 @@ mlx4_set_link_up(struct rte_eth_dev *dev) priv_unlock(priv); return err; } + /** * DPDK callback to get information about the device. * @@ -2417,7 +2422,6 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) char ifname[IF_NAMESIZE]; info->pci_dev = RTE_ETH_DEV_TO_PCI(dev); - if (priv == NULL) return; priv_lock(priv); @@ -2562,7 +2566,6 @@ mlx4_link_update(struct rte_eth_dev *dev, int wait_to_complete) int link_speed = 0; /* priv_lock() is not taken to allow concurrent calls. */ - if (priv == NULL) { rte_errno = EINVAL; return -rte_errno; @@ -2657,7 +2660,6 @@ mlx4_dev_get_flow_ctrl(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) strerror(rte_errno)); goto out; } - fc_conf->autoneg = ethpause.autoneg; if (ethpause.rx_pause && ethpause.tx_pause) fc_conf->mode = RTE_FC_FULL; @@ -2668,7 +2670,6 @@ mlx4_dev_get_flow_ctrl(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) else fc_conf->mode = RTE_FC_NONE; ret = 0; - out: priv_unlock(priv); assert(ret >= 0); @@ -2703,13 +2704,11 @@ mlx4_dev_set_flow_ctrl(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) ethpause.rx_pause = 1; else ethpause.rx_pause = 0; - if (((fc_conf->mode & RTE_FC_FULL) == RTE_FC_FULL) || (fc_conf->mode & RTE_FC_TX_PAUSE)) ethpause.tx_pause = 1; else ethpause.tx_pause = 0; - priv_lock(priv); if (priv_ifreq(priv, SIOCETHTOOL, &ifr)) { ret = rte_errno; @@ -2719,7 +2718,6 @@ mlx4_dev_set_flow_ctrl(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) goto out; } ret = 0; - out: priv_unlock(priv); assert(ret >= 0); @@ -2953,8 +2951,8 @@ mlx4_dev_link_status_handler(void *arg) ret = priv_dev_status_handler(priv, dev, &events); priv_unlock(priv); if (ret > 0 && events & (1 << RTE_ETH_EVENT_INTR_LSC)) - _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL, - NULL); + _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, + NULL, NULL); } /** @@ -3001,6 +2999,7 @@ mlx4_dev_interrupt_handler(void *cb_arg) * Pointer to private structure. * @param dev * Pointer to the rte_eth_dev structure. + * * @return * 0 on success, negative errno value otherwise and rte_errno is set. */ @@ -3032,6 +3031,7 @@ priv_dev_interrupt_handler_uninstall(struct priv *priv, struct rte_eth_dev *dev) * Pointer to private structure. * @param dev * Pointer to the rte_eth_dev structure. + * * @return * 0 on success, negative errno value otherwise and rte_errno is set. */ @@ -3042,8 +3042,9 @@ priv_dev_interrupt_handler_install(struct priv *priv, int flags; int rc; - /* Check whether the interrupt handler has already been installed - * for either type of interrupt + /* + * Check whether the interrupt handler has already been installed + * for either type of interrupt. */ if (priv->intr_conf.lsc && priv->intr_conf.rmv && @@ -3081,6 +3082,7 @@ priv_dev_interrupt_handler_install(struct priv *priv, * Pointer to private structure. * @param dev * Pointer to the rte_eth_dev structure. + * * @return * 0 on success, negative errno value otherwise and rte_errno is set. */ @@ -3102,6 +3104,7 @@ priv_dev_removal_interrupt_handler_uninstall(struct priv *priv, * Pointer to private structure. * @param dev * Pointer to the rte_eth_dev structure. + * * @return * 0 on success, negative errno value otherwise and rte_errno is set. */ @@ -3135,6 +3138,7 @@ priv_dev_link_interrupt_handler_uninstall(struct priv *priv, * Pointer to private structure. * @param dev * Pointer to the rte_eth_dev structure. + * * @return * 0 on success, negative errno value otherwise and rte_errno is set. */ @@ -3160,6 +3164,7 @@ priv_dev_link_interrupt_handler_install(struct priv *priv, * Pointer to private structure. * @param dev * Pointer to the rte_eth_dev structure. + * * @return * 0 on success, negative errno value otherwise and rte_errno is set. */ @@ -3450,7 +3455,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) (void)pci_drv; assert(pci_drv == &mlx4_driver); - list = ibv_get_device_list(&i); if (list == NULL) { rte_errno = errno; @@ -3501,14 +3505,12 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) return -rte_errno; } ibv_dev = list[i]; - DEBUG("device opened"); if (ibv_query_device(attr_ctx, &device_attr)) { rte_errno = ENODEV; goto error; } INFO("%u port(s) detected", device_attr.phys_port_cnt); - for (i = 0; i < device_attr.phys_port_cnt; ++i) conf.ports.present |= 1 << i; if (mlx4_args(pci_dev->device.devargs, &conf)) { @@ -3531,15 +3533,12 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) /* If port is not enabled, skip. */ if (!(conf.ports.enabled & (1 << i))) continue; - DEBUG("using port %u", port); - ctx = ibv_open_device(ibv_dev); if (ctx == NULL) { rte_errno = ENODEV; goto port_error; } - /* Check port status. */ err = ibv_query_port(ctx, port, &port_attr); if (err) { @@ -3547,19 +3546,16 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) ERROR("port query failed: %s", strerror(rte_errno)); goto port_error; } - if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) { rte_errno = ENOTSUP; ERROR("port %d is not configured in Ethernet mode", port); goto port_error; } - if (port_attr.state != IBV_PORT_ACTIVE) DEBUG("port %d is not active: \"%s\" (%d)", port, ibv_port_state_str(port_attr.state), port_attr.state); - /* Allocate protection domain. */ pd = ibv_alloc_pd(ctx); if (pd == NULL) { @@ -3567,7 +3563,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) ERROR("PD allocation failure"); goto port_error; } - /* from rte_ethdev.c */ priv = rte_zmalloc("ethdev private structure", sizeof(*priv), @@ -3577,13 +3572,11 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) ERROR("priv allocation failure"); goto port_error; } - priv->ctx = ctx; priv->device_attr = device_attr; priv->port = port; priv->pd = pd; priv->mtu = ETHER_MTU; - priv->vf = vf; /* Configure the first MAC address by default. */ if (priv_get_mac(priv, &mac.addr_bytes)) { @@ -3614,7 +3607,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) /* Get actual MTU if possible. */ priv_get_mtu(priv, &priv->mtu); DEBUG("port %u MTU is %u", priv->port, priv->mtu); - /* from rte_ethdev.c */ { char name[RTE_ETH_NAME_MAX_LEN]; @@ -3628,15 +3620,11 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) rte_errno = ENOMEM; goto port_error; } - eth_dev->data->dev_private = priv; eth_dev->data->mac_addrs = &priv->mac; eth_dev->device = &pci_dev->device; - rte_eth_copy_pci_info(eth_dev, pci_dev); - eth_dev->device->driver = &mlx4_driver.driver; - /* * Copy and override interrupt handle to prevent it from * being shared between all ethdev instances of a given PCI @@ -3645,11 +3633,9 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) */ priv->intr_handle_dev = *eth_dev->intr_handle; eth_dev->intr_handle = &priv->intr_handle_dev; - priv->dev = eth_dev; eth_dev->dev_ops = &mlx4_dev_ops; eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE; - /* Bring Ethernet device up. */ DEBUG("forcing Ethernet interface up"); priv_set_flags(priv, ~IFF_UP, IFF_UP); @@ -3657,7 +3643,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) mlx4_link_update(eth_dev, 0); continue; - port_error: rte_free(priv); if (pd) @@ -3670,14 +3655,12 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) } if (i == device_attr.phys_port_cnt) return 0; - /* * XXX if something went wrong in the loop above, there is a resource * leak (ctx, pd, priv, dpdk ethdev) but we can do nothing about it as * long as the dpdk does not provide a way to deallocate a ethdev and a * way to enumerate the registered ethdevs to free the previous ones. */ - error: if (attr_ctx) claim_zero(ibv_close_device(attr_ctx)); diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 58d4698..7dcb059 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -835,7 +835,6 @@ priv_flow_create_action_queue(struct priv *priv, goto error; } return rte_flow; - error: rte_free(rte_flow); return NULL;