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: 10549653 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AE4E314E2 for ; Mon, 30 Jul 2018 22:05:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81A232A127 for ; Mon, 30 Jul 2018 22:05:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73CDB2A135; Mon, 30 Jul 2018 22:05:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F00522A127 for ; Mon, 30 Jul 2018 22:05:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730983AbeG3Xmp (ORCPT ); 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-Google-Smtp-Source: AAOMgpcHubtPGB0pXFGOUS8m5vYFef+EvtucQ5pbiSwhxRUnJkj1Gm4tVuAschOPbtTckEN6SDQ/og== 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 X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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 */