From patchwork Mon Jul 30 22:05:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 143174 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4572779ljj; Mon, 30 Jul 2018 15:05:46 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd4Ffvwk7CBxzDzOqF4I91M7RcVzkVPHbZNG5pWMIHhpNViYBJvwOw/Af2ITymlJ/oHKkuy X-Received: by 2002:a17:902:740b:: with SMTP id g11-v6mr18052758pll.85.1532988345947; Mon, 30 Jul 2018 15:05:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532988345; cv=none; d=google.com; s=arc-20160816; b=PgQL3+7ObzsltSD+am0POfFcr5y4L9uIWgKFUYkn/CmiSzhva/DCvkaCuTiqJlBS/q id2Y+WPq4u+zuQ2wMHnrSEoci3qmZmWZ+/g7/os6ToNxb6NNWnwxywU774BYHojbwuGB RbDmCJGk6r1YAFAMCN1Px29XGymyu9mHCsv80+/SiiQ4Ry2Snqh1ES0Sj2YtnMuLuw4t QegKoKN1nevwdhEdUGHojMGcD8SJ5EMdHR8Vk+gPeQCRcBZJjYJ03qEUtGFaC8deD5Hx 5KoOhAWfLl+O/t6GqbU+ZBgI0iF92Jvn9ghsvxzx0RD68LfIxUOs+TZmp6YM4beXsAj6 CPRg== 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:arc-authentication-results; bh=yJVdPzeXwhF606F9IcfJU7f/HkS1jL2H6aaGudCwIVc=; b=dxTDe8RKEc02zs0BoOwnAc0BJlo4zGtKzlI7JNh4qzrE9sPC0ZQntl0Vo04zfqekXo 8ysi9Bp3IRUxB9FYIMpGBAVrJySx6TAIABvvXHB0xXQ/YY8r4BHfCfbbzfEGOazdacWb 4KvI//ZuD5QphvvOsjrBIBOtP6lHTJx74KPxPtX1JFQPVBxA9BnPln5k+Ut0mf5055Ek zzO1cZZETBElCNXismDWyWdgfilZLIlmFRLZbRGXFm4xLKv/A7AQ8Fkwl17JoxlpKRCH xPGpaWoRTH5I9Wq/1+1UCDoqKsmixxAqQf2gz3HTAtbIe8y9bfwbjt1WE7wBQVIdvPQY ru2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EpeC+yyT; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (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 i24-v6si12414021pgj.228.2018.07.30.15.05.45; Mon, 30 Jul 2018 15:05:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EpeC+yyT; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730983AbeG3Xmp (ORCPT + 5 others); Mon, 30 Jul 2018 19:42:45 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:40166 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728701AbeG3Xmp (ORCPT ); Mon, 30 Jul 2018 19:42:45 -0400 Received: by mail-lj1-f194.google.com with SMTP id j19-v6so11861852ljc.7 for ; Mon, 30 Jul 2018 15:05:43 -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=e/5Df3GfYNL2NR37dOp8MdMESR5yMsZb7sZ0YNOIllA=; b=EpeC+yyTrMSQJpDSc29JHwWNINnNmEIlQ6ozw7fNwxAMGzgpmGNEOPEZr8td58Mczb /NmGaxykojG5ocyxBDO8105F9eBUjov9kOMEg90bYRLB053AgECA4wMphdTGqat4OZxu Pz7RJh1iLTHyIKJOTOfl2BOaCLsY8sTfDczlU= 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=e/5Df3GfYNL2NR37dOp8MdMESR5yMsZb7sZ0YNOIllA=; b=HEm9Z25lwcYoPmdU6l632ttbyY2SGEhsdAg8mM+BxJpzMf5yVUyMGg+z76xudNUtYb Zxs6OQLdApOQwXIx8EScsE8kQmOSFcCuVe5vMn4h9klblqj8dAvb1Cs9K96W4H2YXjHt zvQpHDebHpo4/WxxN3f5o4rfDKH+Y5o+JzRNkXjPUGz5qbJaXTa601prs7mnHx6QOl8h PXyyFrMb9p0FvDP8m2hrACIK65HehN+PbT29QPpsE0f4Ixlgjz8Bed3FaHIoqQVyVbut Zw2WjVZI3bBKGcuCNLLgI9Fj8mLMmqfG8ZpN4CWOzvBASASncrTeYdpBET5K8korwfJO Vl4w== X-Gm-Message-State: AOUpUlGwhnSLaIHVALGcH9LD+gmf9AdoTu9AwXkcbDE7pXLwUJLLPS8d sWVldQwGrd41sOPRkwDGhy7/tw== X-Received: by 2002:a2e:2067:: with SMTP id g100-v6mr2767227ljg.138.1532988342793; Mon, 30 Jul 2018 15:05:42 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id k68-v6sm1696499lfg.22.2018.07.30.15.05.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jul 2018 15:05:41 -0700 (PDT) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, davem@davemloft.net Cc: linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, joe@perches.com, andrew@lunn.ch, Ivan Khoronzhuk Subject: [PATCH v4 net-next] net: ethernet: ti: cpsw: replace unnecessarily macroses on functions Date: Tue, 31 Jul 2018 01:05:39 +0300 Message-Id: <20180730220539.12319-1-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Replace ugly macroses on functions. Reviewed-by: Grygorii Strashko Signed-off-by: Ivan Khoronzhuk --- Based on net-next/master v4..v3: - use directly code instead of cpsw_src_port_detect() v3..v2: - comment corrections v2..v1: - removed inline for cpsw_src_port_detect() drivers/net/ethernet/ti/cpsw.c | 58 +++++++++++++++------------------- 1 file changed, 26 insertions(+), 32 deletions(-) -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 1b54c26c2bec..f051ce35a440 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -565,40 +565,28 @@ static const struct cpsw_stats cpsw_gstrings_ch_stats[] = { (func)(slave++, ##arg); \ } while (0) -#define cpsw_dual_emac_src_port_detect(cpsw, status, ndev, skb) \ - do { \ - if (!cpsw->data.dual_emac) \ - break; \ - if (CPDMA_RX_SOURCE_PORT(status) == 1) { \ - ndev = cpsw->slaves[0].ndev; \ - skb->dev = ndev; \ - } else if (CPDMA_RX_SOURCE_PORT(status) == 2) { \ - ndev = cpsw->slaves[1].ndev; \ - skb->dev = ndev; \ - } \ - } while (0) -#define cpsw_add_mcast(cpsw, priv, addr) \ - do { \ - if (cpsw->data.dual_emac) { \ - struct cpsw_slave *slave = cpsw->slaves + \ - priv->emac_port; \ - int slave_port = cpsw_get_slave_port( \ - slave->slave_num); \ - cpsw_ale_add_mcast(cpsw->ale, addr, \ - 1 << slave_port | ALE_PORT_HOST, \ - ALE_VLAN, slave->port_vlan, 0); \ - } else { \ - cpsw_ale_add_mcast(cpsw->ale, addr, \ - ALE_ALL_PORTS, \ - 0, 0, 0); \ - } \ - } while (0) - static inline int cpsw_get_slave_port(u32 slave_num) { return slave_num + 1; } +static void cpsw_add_mcast(struct cpsw_priv *priv, u8 *addr) +{ + struct cpsw_common *cpsw = priv->cpsw; + + if (cpsw->data.dual_emac) { + struct cpsw_slave *slave = cpsw->slaves + priv->emac_port; + int slave_port = cpsw_get_slave_port(slave->slave_num); + + cpsw_ale_add_mcast(cpsw->ale, addr, + 1 << slave_port | ALE_PORT_HOST, + ALE_VLAN, slave->port_vlan, 0); + return; + } + + cpsw_ale_add_mcast(cpsw->ale, addr, ALE_ALL_PORTS, 0, 0, 0); +} + static void cpsw_set_promiscious(struct net_device *ndev, bool enable) { struct cpsw_common *cpsw = ndev_to_cpsw(ndev); @@ -706,7 +694,7 @@ static void cpsw_ndo_set_rx_mode(struct net_device *ndev) /* program multicast address list into ALE register */ netdev_for_each_mc_addr(ha, ndev) { - cpsw_add_mcast(cpsw, priv, (u8 *)ha->addr); + cpsw_add_mcast(priv, ha->addr); } } } @@ -798,10 +786,16 @@ static void cpsw_rx_handler(void *token, int len, int status) struct sk_buff *skb = token; struct sk_buff *new_skb; struct net_device *ndev = skb->dev; - int ret = 0; + int ret = 0, port; struct cpsw_common *cpsw = ndev_to_cpsw(ndev); - cpsw_dual_emac_src_port_detect(cpsw, status, ndev, skb); + if (cpsw->data.dual_emac) { + port = CPDMA_RX_SOURCE_PORT(status); + if (port) { + ndev = cpsw->slaves[--port].ndev; + skb->dev = ndev; + } + } if (unlikely(status < 0) || unlikely(!netif_running(ndev))) { /* In dual emac mode check for all interfaces */