From patchwork Tue Jul 9 21:14:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 168772 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp9044592ilk; Tue, 9 Jul 2019 14:14:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNJKrhAIbVlwgWiTa07zGqf+GRV+vVR4YlPtSyC75ciOpri4dfTbgfv37spAkS0Rym5oMD X-Received: by 2002:a63:61cb:: with SMTP id v194mr30932375pgb.95.1562706896277; Tue, 09 Jul 2019 14:14:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562706896; cv=none; d=google.com; s=arc-20160816; b=bosZ3H46y4Jh36w7LV/BEAZe/ya1J8klo4ye5q1TEfivjxMJqASvrw0P9zZtqA10E9 Sj8THE7JqAgL4w1eAnkNIsgpYuwCPmo0y7FG6TxUYWgXurMDIpAfMkw+J8eC4isnwp7b H4PvVqVS13075TdaQXWm5p7lkFiYSBYvernfJVYAqqY48QlLYZykGsBzR1vdCZPfmE2P V2RC6CTLavJF1ffIkJ2mXeez2rS/jqpnitOPD7fjuxQ1ZHB1QZyhf4YcZbLpFxuflRCX qgYqxwdsXBQ6w1hUfndRWjtA3bhy4v4Z00Faul84j2ZHz3Xt+D6J7ElBNeGKlBL8DN12 OFhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=BVgDE9EsWjVM3bqmvwfPChhBvjPtL3gYpX7TM72N+sA=; b=dXa3HPXT5Y3lEMn4PzItH2C1tDlhDTyepMU+i66STZKCgtGQdVLU1GTVQSeUvzeQDC SWSwLyrznfci9TD82o3uV5302wGjKEWWOyvtmexFN/UNg3dxDfm6fsARBS7cvzJkWDjA z+obmet1niLL+/3UsHvpExLPmWbm6XjM9wzFTGRNrauHyrR4x8lGIiSgSrX4viwEZFyn 8WKdMUYdPrnifA++uGdReENt42bhClPh55rBrlZBVqUyG7+Qtyb4yqo2vPy0FoZBqrXH WD9dmVkxzhDMd8qkzDoJWiu4kr4y1KzkiUg1kkomkGCdAMe7kSA+DSDGtJswOriBsAcK om6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EXZ1HQzb; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w21si39691pff.263.2019.07.09.14.14.56; Tue, 09 Jul 2019 14:14:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EXZ1HQzb; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727436AbfGIVOz (ORCPT + 9 others); Tue, 9 Jul 2019 17:14:55 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:55135 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726318AbfGIVOy (ORCPT ); Tue, 9 Jul 2019 17:14:54 -0400 Received: by mail-wm1-f67.google.com with SMTP id p74so183573wme.4 for ; Tue, 09 Jul 2019 14:14:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=BVgDE9EsWjVM3bqmvwfPChhBvjPtL3gYpX7TM72N+sA=; b=EXZ1HQzbMDtPfA7Q8fsaHbaNfjIsYBwDpX1G8PimVAvWnYbr84zWuKBsFtSrLS2tyi 5LAwHMGTe8hP1/FGpZfT2s8M/tkzrIyf1KJRNhOm1oqfwJW4nUNliSkn2tHhlTHLuMJS cBDigzkXdOduUdsNcImmkbY+8zOLSsfVqemhAULeDCglwo/li9g3sG4tBIp+ZmO4aqdb Rr5x5Ae4Z8EGqMSGpbg2fkeiwRh08vm/O/yxMX4saDRlgdr/+HXxtwYD3ot+11jwLoVM 1H7psQJD2JhqvMWTw3NmDCqTlW11fPSqqOmEkYzKACp4TP9p7QZuiX92D/HceWbIbicb bJxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BVgDE9EsWjVM3bqmvwfPChhBvjPtL3gYpX7TM72N+sA=; b=GT8Wi46kGuXM6RfOTPOX5O6Y9lzMddADw7d2HWJGw3tZ7YhahQvTnPnae0dzlEyV+k 1fy0Lcp8Jsg9k0IWbqLqywg9DZA2//k5pUmt695llfGEV/cwp7EegxTJr+x8tbpllmW2 ow7bW6Z9zHI89ZYNc+5LG65CFtdxm+pByAL0bBpMSoIi3LsYImZL4a+8UG1OrRmELqUS 8UX3pTJBgQ7YVnZKtmYp2MnvHWTYD56WVPayo1TFp5L1ZpqEskFNPK+ieYkBwQiPExsA CC+1LId5YeiuBmK5t8Y+jRupD+GmFsy0EvXrtZJP5iLiEkFa6G/25TF82r9oDCnKG9fh 4r2g== X-Gm-Message-State: APjAAAVlIyiwRUJfSrInpupAAKVEAKfOhRU+7Vcu2BrMi+qmNoak3rRJ f2Q34qLffoC1ZtHzYbfdo9VyrP0aiFM= X-Received: by 2002:a1c:a5c2:: with SMTP id o185mr1416602wme.172.1562706892283; Tue, 09 Jul 2019 14:14:52 -0700 (PDT) Received: from apalos.lan (athedsl-428434.home.otenet.gr. [79.131.225.144]) by smtp.gmail.com with ESMTPSA id c1sm51464wrh.1.2019.07.09.14.14.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Jul 2019 14:14:51 -0700 (PDT) From: Ilias Apalodimas To: netdev@vger.kernel.org, jaswinder.singh@linaro.org, davem@davemloft.net Cc: Ilias Apalodimas Subject: [PATCH 1/2] net: netsec: remove superfluous if statement Date: Wed, 10 Jul 2019 00:14:48 +0300 Message-Id: <1562706889-15471-1-git-send-email-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org While freeing tx buffers the memory has to be unmapped if the packet was an skb or was used for .ndo_xdp_xmit using the same arguments. Get rid of the unneeded extra 'else if' statement Signed-off-by: Ilias Apalodimas --- drivers/net/ethernet/socionext/netsec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index c3a4f86f56ee..7f9280f1fb28 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -654,12 +654,12 @@ static bool netsec_clean_tx_dring(struct netsec_priv *priv) eop = (entry->attr >> NETSEC_TX_LAST) & 1; dma_rmb(); - if (desc->buf_type == TYPE_NETSEC_SKB) + /* if buf_type is either TYPE_NETSEC_SKB or + * TYPE_NETSEC_XDP_NDO we mapped it + */ + if (desc->buf_type != TYPE_NETSEC_XDP_TX) dma_unmap_single(priv->dev, desc->dma_addr, desc->len, DMA_TO_DEVICE); - else if (desc->buf_type == TYPE_NETSEC_XDP_NDO) - dma_unmap_single(priv->dev, desc->dma_addr, - desc->len, DMA_TO_DEVICE); if (!eop) goto next; From patchwork Tue Jul 9 21:14:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 168773 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp9044636ilk; Tue, 9 Jul 2019 14:14:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvQlJIjjLXD5E1iGC7U0AAS7O9iNo7wkThTgDdNCR9zFvVVzczHt4dTkyGp7Ot3mlNur8q X-Received: by 2002:a63:e24c:: with SMTP id y12mr31895294pgj.81.1562706898605; Tue, 09 Jul 2019 14:14:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562706898; cv=none; d=google.com; s=arc-20160816; b=v3fQMx9sswZV/lIfFlsgPNFoo6Qe7AsjEM9tsgB5CVbRx6BpkHF12flzGg49wMdkGH cFgiFz4O8qCNEJRDlPcafHmhnPRcppZspXYqQo85j/oEb5ipAUiqufsMjwKtXXQe9gDo RZt2zLl1J8IznAKVx2eCJ09+S/EfQ1eDc+iL2q4LXZUM2uE0+6cEjp/io1G75YfKPkXJ dRQOWPBCYp/EeHTroEm7j0PrwOfz9Wzm8r2EhaqnCwRokVUH5t+GfmJwU9X28uORtuKQ O7JOTHMhTVonRhOXeLEMJenvjmZy7BfhV2g6uSjeZMTq99mKqcRWuHElcee/7BcT3u1s D3gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=rj+99i2uwCJ8cSFTtOPthReWg8Dntdmo/7awzx9PpEk=; b=bRMH3nxCwygnE5Q1pHmyqaIgah1mgKBIsUIFAYMXtrjpoNDYzJ3gXUbkvJhKfHMGNN iKlz5/P/FDFRVL4VIybqJGQXjBEVO3yZY24wA+IvrNaWznwqH6Q/6J4AI91G0zdEVQFF CfhkFmqPuGE51Z4nlFxTt/sXT/RDO9OmsSSonMgwu3M1J/rhrE4Orxf3E9vUDLe0gQOW CmEibGwiRzQW4Bi78nZ13VKbyLJj1KT/7ZrIHLZ1ZTPyHfV1pKtb3d34NMRD6U7JpTIu BCMcSj88pgnktbb1Ef6sIKyTvz4/m1AWJcXfFzkUW1hXvfNajbwnLDYqxb9LmOC9qiQo CcFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jIuK8xkW; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w21si39691pff.263.2019.07.09.14.14.58; Tue, 09 Jul 2019 14:14:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jIuK8xkW; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727758AbfGIVO5 (ORCPT + 9 others); Tue, 9 Jul 2019 17:14:57 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43238 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727032AbfGIVO4 (ORCPT ); Tue, 9 Jul 2019 17:14:56 -0400 Received: by mail-wr1-f67.google.com with SMTP id p13so251227wru.10 for ; Tue, 09 Jul 2019 14:14:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rj+99i2uwCJ8cSFTtOPthReWg8Dntdmo/7awzx9PpEk=; b=jIuK8xkW3NhYHJv+zJu/2lHhMf3mmjM6dh/a5ED2EqiVvPnikMklDD0kcC/zO8yzFy CW3GWHjHl+8gqUKon7MqCItdB4Ot2QtXGjBMw8HsFOQDNR8vppl9vaicpjOwJ8auADXT hFLWXaBTSeMwOO02njHpZl5yWjiamkSAsGHo5a7Y1T2Faek7XPF/JbKRm3kuzTr9Uohf X4SMmsu2HG7P15IRsYhubv8mtn7RYFqezVzK/Rg5qcs7G3X/vWj4wNO9bFmeE+E9jJ8n adxRgtzJjcxuKV0cjVueExVGm2C82K/AmG2pGMovGa0lPSYKSyQDQ46T+E8H2JVfJaVw Z1Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rj+99i2uwCJ8cSFTtOPthReWg8Dntdmo/7awzx9PpEk=; b=RxN8JfAwmWhM5wEVQYAyTVqB9F0xxo1Bef3eEtNZUELTkV0N3dZ28AUmH20tv4S/XP rorHr7jCunVaLl28sdDx6EwjJUen1+vJhe/9QrpnQpKwKvtR6A6JGohOUu842lsF3E4V uCuI5CV9PC+IlJ1biYJFm+dAmbz329k++jnebABlrzk3jqjGz8poR13kf4F2o8pBBwpq Rf2GwJGULrEmcmMdEf5DvjKt/VlZHk2mtAN6ueuDnkLqgP4FL6EYvX+cOO9xJHMMMi0E HcsJEqqBzaWmTMCiyZzxk83C1WjRoUlVSTxhyU/nIfBChvvbiTVSSau/9mQAA9TcjrGL DRYg== X-Gm-Message-State: APjAAAVsrZdupIeU5Ja+PXmDDF5RzQzHOvQPbLlg9RgPRDb0CNtl6toG UpRdlofhQG0ngalA2TGX7LZZFutJB90= X-Received: by 2002:adf:a514:: with SMTP id i20mr28211032wrb.281.1562706893660; Tue, 09 Jul 2019 14:14:53 -0700 (PDT) Received: from apalos.lan (athedsl-428434.home.otenet.gr. [79.131.225.144]) by smtp.gmail.com with ESMTPSA id c1sm51464wrh.1.2019.07.09.14.14.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Jul 2019 14:14:52 -0700 (PDT) From: Ilias Apalodimas To: netdev@vger.kernel.org, jaswinder.singh@linaro.org, davem@davemloft.net Cc: Ilias Apalodimas Subject: [PATCH 2/2] net: netsec: remove static declaration for netsec_set_tx_de() Date: Wed, 10 Jul 2019 00:14:49 +0300 Message-Id: <1562706889-15471-2-git-send-email-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1562706889-15471-1-git-send-email-ilias.apalodimas@linaro.org> References: <1562706889-15471-1-git-send-email-ilias.apalodimas@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On commit ba2b232108d3 ("net: netsec: add XDP support") a static declaration for netsec_set_tx_de() was added to make the diff easier to read. Now that the patch is merged let's move the functions around and get rid of that Signed-off-by: Ilias Apalodimas --- drivers/net/ethernet/socionext/netsec.c | 86 ++++++++++++------------- 1 file changed, 41 insertions(+), 45 deletions(-) -- 2.20.1 diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index 7f9280f1fb28..1502fe8b0456 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -328,11 +328,6 @@ struct netsec_rx_pkt_info { bool err_flag; }; -static void netsec_set_tx_de(struct netsec_priv *priv, - struct netsec_desc_ring *dring, - const struct netsec_tx_pkt_ctrl *tx_ctrl, - const struct netsec_desc *desc, void *buf); - static void netsec_write(struct netsec_priv *priv, u32 reg_addr, u32 val) { writel(val, priv->ioaddr + reg_addr); @@ -778,6 +773,47 @@ static void netsec_finalize_xdp_rx(struct netsec_priv *priv, u32 xdp_res, netsec_xdp_ring_tx_db(priv, pkts); } +static void netsec_set_tx_de(struct netsec_priv *priv, + struct netsec_desc_ring *dring, + const struct netsec_tx_pkt_ctrl *tx_ctrl, + const struct netsec_desc *desc, void *buf) +{ + int idx = dring->head; + struct netsec_de *de; + u32 attr; + + de = dring->vaddr + (DESC_SZ * idx); + + attr = (1 << NETSEC_TX_SHIFT_OWN_FIELD) | + (1 << NETSEC_TX_SHIFT_PT_FIELD) | + (NETSEC_RING_GMAC << NETSEC_TX_SHIFT_TDRID_FIELD) | + (1 << NETSEC_TX_SHIFT_FS_FIELD) | + (1 << NETSEC_TX_LAST) | + (tx_ctrl->cksum_offload_flag << NETSEC_TX_SHIFT_CO) | + (tx_ctrl->tcp_seg_offload_flag << NETSEC_TX_SHIFT_SO) | + (1 << NETSEC_TX_SHIFT_TRS_FIELD); + if (idx == DESC_NUM - 1) + attr |= (1 << NETSEC_TX_SHIFT_LD_FIELD); + + de->data_buf_addr_up = upper_32_bits(desc->dma_addr); + de->data_buf_addr_lw = lower_32_bits(desc->dma_addr); + de->buf_len_info = (tx_ctrl->tcp_seg_len << 16) | desc->len; + de->attr = attr; + /* under spin_lock if using XDP */ + if (!dring->is_xdp) + dma_wmb(); + + dring->desc[idx] = *desc; + if (desc->buf_type == TYPE_NETSEC_SKB) + dring->desc[idx].skb = buf; + else if (desc->buf_type == TYPE_NETSEC_XDP_TX || + desc->buf_type == TYPE_NETSEC_XDP_NDO) + dring->desc[idx].xdpf = buf; + + /* move head ahead */ + dring->head = (dring->head + 1) % DESC_NUM; +} + /* The current driver only supports 1 Txq, this should run under spin_lock() */ static u32 netsec_xdp_queue_one(struct netsec_priv *priv, struct xdp_frame *xdpf, bool is_ndo) @@ -1041,46 +1077,6 @@ static int netsec_napi_poll(struct napi_struct *napi, int budget) return done; } -static void netsec_set_tx_de(struct netsec_priv *priv, - struct netsec_desc_ring *dring, - const struct netsec_tx_pkt_ctrl *tx_ctrl, - const struct netsec_desc *desc, void *buf) -{ - int idx = dring->head; - struct netsec_de *de; - u32 attr; - - de = dring->vaddr + (DESC_SZ * idx); - - attr = (1 << NETSEC_TX_SHIFT_OWN_FIELD) | - (1 << NETSEC_TX_SHIFT_PT_FIELD) | - (NETSEC_RING_GMAC << NETSEC_TX_SHIFT_TDRID_FIELD) | - (1 << NETSEC_TX_SHIFT_FS_FIELD) | - (1 << NETSEC_TX_LAST) | - (tx_ctrl->cksum_offload_flag << NETSEC_TX_SHIFT_CO) | - (tx_ctrl->tcp_seg_offload_flag << NETSEC_TX_SHIFT_SO) | - (1 << NETSEC_TX_SHIFT_TRS_FIELD); - if (idx == DESC_NUM - 1) - attr |= (1 << NETSEC_TX_SHIFT_LD_FIELD); - - de->data_buf_addr_up = upper_32_bits(desc->dma_addr); - de->data_buf_addr_lw = lower_32_bits(desc->dma_addr); - de->buf_len_info = (tx_ctrl->tcp_seg_len << 16) | desc->len; - de->attr = attr; - /* under spin_lock if using XDP */ - if (!dring->is_xdp) - dma_wmb(); - - dring->desc[idx] = *desc; - if (desc->buf_type == TYPE_NETSEC_SKB) - dring->desc[idx].skb = buf; - else if (desc->buf_type == TYPE_NETSEC_XDP_TX || - desc->buf_type == TYPE_NETSEC_XDP_NDO) - dring->desc[idx].xdpf = buf; - - /* move head ahead */ - dring->head = (dring->head + 1) % DESC_NUM; -} static int netsec_desc_used(struct netsec_desc_ring *dring) {