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: 143099 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1374083ljj; Fri, 27 Jul 2018 15:57:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeuBzWdJTwgLeHiG6wNa2YTO2fZ4QOT0DTxuAtDiEPMQeB5UN1PTbvbhsklaczZ6yvvw7gs X-Received: by 2002:a17:902:722:: with SMTP id 31-v6mr6746957pli.207.1532732254498; Fri, 27 Jul 2018 15:57:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532732254; cv=none; d=google.com; s=arc-20160816; b=KwS1pBzx8g4+jzotXDOXo2CKt8gNRAOYsdgyEoitUaCz6QeMl5Cxtxb0POPVJ8AXTD ZRKoF4GdLflix26lS7qwCFg95rB5PjdYvQmjGUVCnbSz9IEPl4Nw1ekBAbDmYhJWl0Ph zG5mGcyZnpjaQQy/quUwG1QTlQd2EAWu35AJszVWqFbnTbaGztpyVmKBuCmvaou0JAce vBIfBIZwOLYicveeZt0grGGaaIcL/YLYA6OzDhzj4y5PB6gxRE8PdIQozDd5DblCJIsS nwu8oQFTfdQakuji9NBd6ThmzZHBHSSw95Td6+vvMP92keeAZMkEw6h3urO4W0541Vih tXzA== 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=sRtS++9tfqeRK26DArN/J83/p+Zu/+Nvsuwm+I5m8Sw=; b=rL/ozUQobYueL8WEj2KzHzqaNqPUKSDX9xNBr96jNQKMuTnGo1ywCjdLhp8rKVWO+q /6A7qEUJquT7vSIwLwjNpVTh33FE9/HMb3Ew0ZGNjpBpTAPpEiqEnJscup+X6IpuBfBB ROSRmgKo7p1d8NvS0XQ6QZedZGtHbrNaz84QFh5lhd9XzYMZYlQfWef8tMRGVhBPNdVN y308fJ3bOtXDifv0DVt/EtS95H4IJQvm+BP6FNF4H1KbR3wXYzCJTZYFjC2ODZugAZ2u jmb+WoBKzNZG0hqDIGkhHMlpX9RNnlli6/JGfVAg2wzmu8XFe+xfEKHh4HW1IKcGSNN+ zu+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NBQXrGdn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (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 33-v6si3886794plh.16.2018.07.27.15.57.34; Fri, 27 Jul 2018 15:57:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NBQXrGdn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389008AbeG1AVd (ORCPT + 31 others); Fri, 27 Jul 2018 20:21:33 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:37377 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388507AbeG1AVd (ORCPT ); Fri, 27 Jul 2018 20:21:33 -0400 Received: by mail-lf1-f65.google.com with SMTP id j8-v6so4539729lfb.4 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=MS3DZqCJUeOdCal82z8NB3e5xnK9x0PS/6L2jLFSJ0v3v1RMo8d4BaILSz/qcjy+Ro xalb5LZodoJooN4T2OWiq6/Kuo+gPkn37HaeEtOkEGOZKo2i4uq87/Dyv/wzeOqVIHYB BRcPC7uuoMk0kgr2P3Ky8vD0PGPVF/g8Y3MI8jFhmSDYiA0RhsVnngBYi4PK8vbbRe2w tBWS3yxDZjWeV2L+4MesWiTNIIWt8Goc7K4MbAEyuuA1D5pCQVL9sskCyYWlWMmz/HNJ HvNAvwS2GqZNnFPpm1HzqRBZIbRWSk4wZul3TYfYLpvXSrO3Py4t4jPRulQD2N27eVix 8y5g== X-Gm-Message-State: AOUpUlGZyX2iWiWW9TP45ooSTxtxBYn+qIiUI2Porkp6DrdAKHuI3wFk dczMru3J79d6F+1DXHFB08Lp3Q== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.17.1 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 */