Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1199227imm; Fri, 27 Jul 2018 12:54:20 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeVgV/tmfvrQHicAoBUpj4VhR3Z9nXO8s+o6onks1+YwnGHiu8J6zPBWiQTPTlPXqiFnL5b X-Received: by 2002:a17:902:8d96:: with SMTP id v22-v6mr7190104plo.176.1532721260565; Fri, 27 Jul 2018 12:54:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532721260; cv=none; d=google.com; s=arc-20160816; b=klUYTLlyfjf2BSL23f+TB6lkanpCb7vWlxgd9lQvCjKtQZsCAJGZgY9fDTfBMZqyae q1iAXx24dId2rgXwuniMkPExJJECFYlhyE6DgpMIWGpT9qmMfNTaK7EUd6+oEvWq47QB dNrmkFf8EKudPFU0KGLo7m5Gt62qKDdt71BsC9GPER2OEBQN+nJMFuDHIj6IJ3CVtJR5 aa3H1BmIVROFU+CQvX5dzfUylH5jkXT6bvB3qC7WKJRqkFyo5x24UFKfQxLz9uSoRZhY H7YoairtiC69ygkD1loSNm1kqkb/FPDflHdzIWRL/O+edsdhqtIRKd7n1+S+TAQdtVvj w8Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:to:from:date:dkim-signature :arc-authentication-results; bh=w3JvfByZvUV0ODKi6DgEyNGOlHS+Qvx52KigecwVaoI=; b=czNVTB9h0RNg8Z0zfZoZZkLVuLAU34MBJ8IvabvzAAE8FChWQGNMMx7wt3z2df4mui 4UMztBpT+kW0VcSfYsV6vhRp6iFvTqmbjBoha8s+lsArueQGoZbWZcd/VrUckc7+imA2 whnrHjiK8n6jSrymCBiaq1wNGWDDuwknNEX0xxbxoagu5clt5QAai5Cwhx9/ju+UK4j6 Ax7l1IEdKsVvgvY4pjUzgNwia1hQhgZ0gmSQVSIOE19qzdmX4fWczfL9LFhhR9zJNwdd PNi3grx7NwsOiN2TjctPzyjUht3BDbC77rDbInzZewC1Q4Ntgm+Qp7uWO2rIfprNyNhe GcXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L+UT53J8; 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 i23-v6si4713455pgb.246.2018.07.27.12.54.06; Fri, 27 Jul 2018 12:54:20 -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=L+UT53J8; 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 S2389569AbeG0VQY (ORCPT + 99 others); Fri, 27 Jul 2018 17:16:24 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:38336 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389326AbeG0VQY (ORCPT ); Fri, 27 Jul 2018 17:16:24 -0400 Received: by mail-lj1-f193.google.com with SMTP id p6-v6so5385589ljc.5 for ; Fri, 27 Jul 2018 12:52:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=w3JvfByZvUV0ODKi6DgEyNGOlHS+Qvx52KigecwVaoI=; b=L+UT53J897pTwKg6LbkSLPcDoDORTwvcylqjllgUQS2EpzaAQK4w/a562jMmBu30QX XNQFluqxiK6mO8SB4xzhRnTeB3YEyZF+KjODC3KOuypAjIrNH1zgaCJ4zfIw89Yhadme PWdhA4aZdc/EcaE1kvYL6r175AcyQDh03o96U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=w3JvfByZvUV0ODKi6DgEyNGOlHS+Qvx52KigecwVaoI=; b=YtIS7VWDrjADV8PvsoiTwpIXUkQ86O2YXPZEnkYqczQlT4n/ew8W4rDgeduz+xNL3H DfN8+YX0s9TojmFDX0PzZd+Xu4L0CacvPoYvwHKBF5iHxzCexzkuASfGc+IruDINJl6a QPzRfL+Z8Iqemes0JttIEzlUNUBc40Es1Xqqr8V0iK5/Vksf69NNBHooIXU1t1pkNbqB NWTVa/NKVZnDilNbMD8DuAnfo3se+4LHekmyRN5zIe5r+qvMfSBvOc0BFrB+W1SxpUGW 1adFXaDsKkv6oCveEEB8kgfHkMnV3OPzV4yxn8SGdlj1MQXosPhFcaBxZHHeX6l6Hh3G SrPw== X-Gm-Message-State: AOUpUlFINkTLdv0/7nuGh3Wz7SOKI4U0fjgZu/EFM+ZHIIKwDkE0ylxn 0n4TYlvuHHeLw2jOjl1mMxk0Vg== X-Received: by 2002:a2e:96d8:: with SMTP id d24-v6mr6384304ljj.50.1532721178822; Fri, 27 Jul 2018 12:52:58 -0700 (PDT) Received: from khorivan (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id f129-v6sm647861lff.37.2018.07.27.12.52.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Jul 2018 12:52:58 -0700 (PDT) Date: Fri, 27 Jul 2018 22:52:56 +0300 From: Ivan Khoronzhuk To: Joe Perches , grygorii.strashko@ti.com, davem@davemloft.net, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next] net: ethernet: ti: cpsw: replace unnecessarily macroses on functions Message-ID: <20180727195254.GB2619@khorivan> Mail-Followup-To: Joe Perches , grygorii.strashko@ti.com, davem@davemloft.net, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180727191318.18698-1-ivan.khoronzhuk@linaro.org> <98a6d1cd4d313512d66ced3fc25f438449b3c310.camel@perches.com> <20180727193641.GA2619@khorivan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20180727193641.GA2619@khorivan> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 27, 2018 at 10:36:43PM +0300, Ivan Khoronzhuk wrote: >On Fri, Jul 27, 2018 at 12:21:07PM -0700, Joe Perches wrote: >>On Fri, 2018-07-27 at 22:13 +0300, Ivan Khoronzhuk wrote: >>>Replace ugly macroses on functions. >> >>Careful, see below. >> >>>diff --git 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; >>>+} >> >>perhaps better as a switch/case >not better, it's shorter. > >> >>>+ >>>+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; >> >>This is not the same code as the new function >>is not guaranteed to succeed or set skb->dev. >Guaranteed by above skb->dev is initialized already. >The function reflects previous macro. > >Even more, seems that here is duplication of ndev=skb->dev; >It should be removed at init ), even if it 100% is optimized by complier. >So guaranteed a little more then needed ), will send v2 with removed >ndev = skb->dev at init if no objection. But no, not duplicates. It's used to get cpsw. So everyting is fine. Patch should go as is. > >> >>> if (unlikely(status < 0) || unlikely(!netif_running(ndev))) { >>> /* In dual emac mode check for all interfaces */ > >-- >Regards, >Ivan Khoronzhuk -- Regards, Ivan Khoronzhuk