From patchwork Fri Jul 27 22:57:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 10547801 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 06111112B for ; Fri, 27 Jul 2018 22:57:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9C642C68B for ; Fri, 27 Jul 2018 22:57:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCA482C699; Fri, 27 Jul 2018 22:57:40 +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 556742C68B for ; Fri, 27 Jul 2018 22:57:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388708AbeG1AVd (ORCPT ); Fri, 27 Jul 2018 20:21:33 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:34266 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730850AbeG1AVd (ORCPT ); Fri, 27 Jul 2018 20:21:33 -0400 Received: by mail-lf1-f67.google.com with SMTP id n96-v6so4538121lfi.1 for ; Fri, 27 Jul 2018 15:57:30 -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=sRtS++9tfqeRK26DArN/J83/p+Zu/+Nvsuwm+I5m8Sw=; b=NBQXrGdnsGRBqQhSTjxpB+QU/eVVifA9ZRvA1yH5KpVypQsRxV+SjRjKFg+ByVgYuP fljA6/+qlnCQQeMw+weumM34iEx5K32mieGWRkniC1K2OegrzddFL5rxVGoXrC/9ehAf U3/z3kIfx5q3pPwvw5DQMOHqP+Gt52k0S7joU= 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=sRtS++9tfqeRK26DArN/J83/p+Zu/+Nvsuwm+I5m8Sw=; b=TFDRHq+3lkHYU70Orq8ROQXqfG1kRF+cidrW6sicOlzf9oQ2NS1Zxjnvy/xa1B8yMJ jhJxBh8dCCKlnNCkWU4a69sinPc9Cs5liTR8TJlaHiW+0daMMkjV3ijsJSAxRmFc24br YleE+6pM8OJPn2RnmKId+b6fx49zo4rALTRhPLogV0Ck3jLQFhop47EIj4ll9tDvXD0i PQkBDyy14rgVUjobFa25sAUyaq/1nCBIaFBR6pC8u8aMvJUYCgO1btUYQQb2/CHtfrd8 W53eaBNaGJaTYnDMTWJSLJ8wgAG4fiRBbf0SJzdrwv8buPJSfGImvJeQJkKzO16vVJDv zKZA== X-Gm-Message-State: AOUpUlEvZR/Junse9AA9CKAX+H3JRp5fe27fAB0yndwBvCWM4f2mpRPB wQ6I0IDK/a8IVdho8/2bQfZ+jGZ0MyQ= X-Google-Smtp-Source: AAOMgpdOk1z3vTXVfijmx0rbIjWG40pGjID0PeaZ7Z3q4SDYBAT6DjkdWazDKpVfOmlnvINpt+mXZg== X-Received: by 2002:a19:db44:: with SMTP id s65-v6mr4867328lfg.109.1532732249722; Fri, 27 Jul 2018 15:57:29 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id h4-v6sm684949lfj.69.2018.07.27.15.57.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jul 2018 15:57:28 -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 v3 net-next] net: ethernet: ti: cpsw: replace unnecessarily macroses on functions Date: Sat, 28 Jul 2018 01:57:25 +0300 Message-Id: <20180727225725.3843-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 v2..v1: - removed inline for cpsw_src_port_detect() 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 */