From patchwork Fri Jul 27 19:13:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 10547645 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 E032B112E for ; Fri, 27 Jul 2018 19:13:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C759E2C426 for ; Fri, 27 Jul 2018 19:13:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B636B2C43D; Fri, 27 Jul 2018 19:13:31 +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 872DD2C426 for ; Fri, 27 Jul 2018 19:13:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389211AbeG0Ugi (ORCPT ); Fri, 27 Jul 2018 16:36:38 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:44008 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389154AbeG0Ugi (ORCPT ); Fri, 27 Jul 2018 16:36:38 -0400 Received: by mail-lf1-f67.google.com with SMTP id f135-v6so4221207lfg.10 for ; Fri, 27 Jul 2018 12:13:23 -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=vEPWKyHQ98lAKCw3xpYUTv1vSr+cHqHxHD2ia9o9nFE=; b=anWEh31uMo+xVMSm5VCxlsZtOM/CEU4w+MBHE67MZ90JYh55YIUszCy7bEXwrmVIN1 GnFLRVdBuvJ043SzMmjf+LF3YLFO/G5SUFgo1sjMlgC0WPvNyDauNrQzM35fyWFJRDJw dPq6XDzRr2aVHt19x7MNr1qowZgzaCvzoNOM0= 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=vEPWKyHQ98lAKCw3xpYUTv1vSr+cHqHxHD2ia9o9nFE=; b=YPez7mbGfOTR/7xXf2kPXUFbsqQLYwgCK7/zlQMSvwsNoo3bKtYFuPH08N4iC+yPaz lBHAXmxFnMEj31exetRad9mT9aN2o3BQccflL9PzA9c78284LP4jzAMMLiJSRkDokVeb RvBMSco29/r6bE/0wCKTxpE47tx31WDhz/JZZQ80JtRXOVAnYvh3HHl19IUJzCob1eRf PAJElUzHCBww2H8PdNCpsXtnj6ugci9FonIs8VcQhKEdmmq7dQd7WlHgdRbyjWRxpGMp Wrlec89U2WQBZKlBIWiw/XtidpcK8ypicE1VQ6KXsj419WSB5Np6TL/UndRxSk25dWyt iNtA== X-Gm-Message-State: AOUpUlFefjyxlxrNSdt05msz+Hdb6EKBLFja4qzEXzMM84mrwq0mtnfg GZFyr4WcTgWklqbkT9yWdyme3Q== X-Google-Smtp-Source: AAOMgpdSlzn6XttHjVoNEDO2Ru43R78fzYWk4vbrXRWtmHKS2424kV99YAdlX7u+8J1tE+Zh/EoAfw== X-Received: by 2002:a19:5d54:: with SMTP id p20-v6mr4633267lfj.143.1532718802274; Fri, 27 Jul 2018 12:13:22 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id 73-v6sm635586lfs.44.2018.07.27.12.13.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jul 2018 12:13:21 -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, Ivan Khoronzhuk Subject: [PATCH net-next] net: ethernet: ti: cpsw: replace unnecessarily macroses on functions Date: Fri, 27 Jul 2018 22:13:18 +0300 Message-Id: <20180727191318.18698-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. Signed-off-by: Ivan Khoronzhuk Reviewed-by: Grygorii Strashko --- Based on net-next/master drivers/net/ethernet/ti/cpsw.c | 63 +++++++++++++++++----------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 1b54c26c2bec..62326a98945b 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -565,40 +565,40 @@ 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 inline void cpsw_src_port_detect(struct cpsw_common *cpsw, int status, + struct sk_buff *skb) +{ + if (!cpsw->data.dual_emac) + return; + + if (CPDMA_RX_SOURCE_PORT(status) == 1) + skb->dev = cpsw->slaves[0].ndev; + else if (CPDMA_RX_SOURCE_PORT(status) == 2) + skb->dev = cpsw->slaves[1].ndev; +} + +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 +706,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, (u8 *)ha->addr); } } } @@ -801,7 +801,8 @@ static void cpsw_rx_handler(void *token, int len, int status) int ret = 0; struct cpsw_common *cpsw = ndev_to_cpsw(ndev); - cpsw_dual_emac_src_port_detect(cpsw, status, ndev, skb); + cpsw_src_port_detect(cpsw, status, skb); + ndev = skb->dev; if (unlikely(status < 0) || unlikely(!netif_running(ndev))) { /* In dual emac mode check for all interfaces */