From patchwork Fri Jul 27 20:49:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 10547721 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 AF494112E for ; Fri, 27 Jul 2018 20:50:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0C5E2C5DC for ; Fri, 27 Jul 2018 20:50:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F38A2C5E1; Fri, 27 Jul 2018 20:50:11 +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 27B882C5EF for ; Fri, 27 Jul 2018 20:50:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389695AbeG0WNk (ORCPT ); Fri, 27 Jul 2018 18:13:40 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:37286 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389482AbeG0WNj (ORCPT ); Fri, 27 Jul 2018 18:13:39 -0400 Received: by mail-lj1-f196.google.com with SMTP id v9-v6so5498940ljk.4 for ; Fri, 27 Jul 2018 13:50:03 -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=NAl3yy/7hIcejXSfbK5GMYeiMaRlfOfS3qnBt7Q+wUY=; b=WpBLoTmFiXfnCpnFEmeFUPy/vbP3B/9MBcXBjycAmGKdehuxQ4WLrRWDh6YOK/t/wh pLcOxmJdRW8V5CCKzxbSAzPF6IwjVUSpB9XHOSjQ7zznXhDGHLi8wJG9/JCIyP8q9ffB jSf1hXU8Qf6616opv0CNhUaw6w5+FAcy03S8g= 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=NAl3yy/7hIcejXSfbK5GMYeiMaRlfOfS3qnBt7Q+wUY=; b=GlviPjVP8JkbBJpn2w1dRhlNHDVXPNVtfFZPkfHobzdHKJRwhspza94+OHytj6zcm6 ScdNWi9Mw+M7xjCe6ymKteILRb8uEEsPvNmsSO1kyz8OgAwSIcPTrUeUcRsRDZtDTITM LImPScvJxrOUXRCnUGkxu+GFCHUPH//uXILiZrEdjZQclhDlQGM/24IFPMfOarkBO43R K50T0WJSnlgC2QkyDcxn6zrAFxe1CPemJZO2W2wylHXV+0dA8S3WNVvbppXW+OkEB4uq rpXR5zhuM15BK8tCYE2yc4eX6hxpM8g0y3jVlNS9VyShryEkN/CkMB1pJ6+IHkSBNMiN T6uQ== X-Gm-Message-State: AOUpUlHFSQ+N23BtQ5gS5zNFVG26c2pweSU2caAC62uuNbVdr7rkKnaf 3QjVdW8dft8394gReiCLAiVm2w== X-Google-Smtp-Source: AAOMgpfk6mR7n+HiVm/CkTaOJ1wEyINRQw3MIBK+1oBVkPmraGvRzsLRt9wvP7iLQyvmBeeOTAb3Ww== X-Received: by 2002:a2e:429c:: with SMTP id h28-v6mr5940082ljf.67.1532724602350; Fri, 27 Jul 2018 13:50:02 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id 14-v6sm812947ljc.74.2018.07.27.13.50.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jul 2018 13:50:01 -0700 (PDT) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, davem@davemloft.net Cc: andrew@lunn.ch, joe@perches.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Ivan Khoronzhuk Subject: [PATCH v2 net-next] net: ethernet: ti: cpsw: replace unnecessarily macroses on functions Date: Fri, 27 Jul 2018 23:49:58 +0300 Message-Id: <20180727204958.23658-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. v2..v1: - removed inline for cpsw_src_port_detect() Reviewed-by: Grygorii Strashko Signed-off-by: Ivan Khoronzhuk --- 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..9cacfe4ad065 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 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 */