From patchwork Thu Jan 19 16:58:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 9526433 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6CEFB60113 for ; Thu, 19 Jan 2017 17:07:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F5FE28616 for ; Thu, 19 Jan 2017 17:07:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5444928628; Thu, 19 Jan 2017 17:07:53 +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=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 ED30928616 for ; Thu, 19 Jan 2017 17:07:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753878AbdASRHt (ORCPT ); Thu, 19 Jan 2017 12:07:49 -0500 Received: from mail-lf0-f52.google.com ([209.85.215.52]:35832 "EHLO mail-lf0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753554AbdASRHd (ORCPT ); Thu, 19 Jan 2017 12:07:33 -0500 Received: by mail-lf0-f52.google.com with SMTP id n124so41301990lfd.2 for ; Thu, 19 Jan 2017 09:07:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WUdMdSbRKAgKeXy/Mw6EZqB7pvQOExhP3XVX8X4F0LQ=; b=HLOh/nVVtiz9b9uZs8/7Ls8pWvyWmuD74qJENMmtiwfiHnirNKpNsSwTSZfV8yxFoi vTIGrGTPN3Axc1Ki886nZModBCes1xkbB7b115kR54Y3TH5M+O5cht6eBoMhhnqB+Vo2 lNpMSnNA4zs09kK+wxcVH7XrXxOswUNm713hg= 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:in-reply-to :references; bh=WUdMdSbRKAgKeXy/Mw6EZqB7pvQOExhP3XVX8X4F0LQ=; b=iKI6bW91lGZYIxx3lt3quhQBOOstVIVdg7tDQO9kyKYJMX524Tokzr95Dc7sLXubw0 hkMPfAlig3UN0FbXtg6yk/F2vakfWMWlLMiRJl+7JCS/pP+tll3bqDSUwyHbSN+UDmSs E7ZVrvWaa0Vxp9ANU5R3c+lvPcEiEu7b4m40lG43HDnWjUkfeTUWS/gJ0UR+ZtygY9OL ICs7ysRLxWQ1jRqv6+XEF1tKVvYjWwKu19DBmWIuMXgjK+15HVxrimWzOSSNzqqeDL8S JtcSI5+NsdCr/goNPk7AwbW9i6HPxk8f0jECsN9Ys+rRASNQd9ZqLURJYR2lPDpraRRd VY2w== X-Gm-Message-State: AIkVDXJa4IylVJpm5gYxnHiqQZKRPb/GitMXNv1b88oKlNNUz9zqU8M+wuIScim3+RiZ7dH9 X-Received: by 10.25.190.205 with SMTP id o196mr3558183lff.130.1484845115080; Thu, 19 Jan 2017 08:58:35 -0800 (PST) Received: from khorivan.synapse.com ([2001:67c:2e5c:2011:b088:28ef:5680:e1cf]) by smtp.gmail.com with ESMTPSA id r27sm2162942ljd.14.2017.01.19.08.58.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Jan 2017 08:58:34 -0800 (PST) From: Ivan Khoronzhuk To: mugunthanvnm@ti.com Cc: grygorii.strashko@ti.com, netdev@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Ivan Khoronzhuk Subject: [PATCH v2 4/5] net: ethernet: ti: cpsw: don't duplicate common res in rx handler Date: Thu, 19 Jan 2017 18:58:26 +0200 Message-Id: <1484845107-30331-5-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484845107-30331-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1484845107-30331-1-git-send-email-ivan.khoronzhuk@linaro.org> 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 No need to duplicate the same function in rx handler to get info if any interface is running. Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/cpsw.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index c681d39..1f14afd 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -671,6 +671,18 @@ static void cpsw_intr_disable(struct cpsw_common *cpsw) return; } +static int cpsw_get_usage_count(struct cpsw_common *cpsw) +{ + u32 i; + u32 usage_count = 0; + + for (i = 0; i < cpsw->data.slaves; i++) + if (netif_running(cpsw->slaves[i].ndev)) + usage_count++; + + return usage_count; +} + static void cpsw_tx_handler(void *token, int len, int status) { struct netdev_queue *txq; @@ -703,18 +715,10 @@ static void cpsw_rx_handler(void *token, int len, int status) cpsw_dual_emac_src_port_detect(cpsw, status, ndev, skb); if (unlikely(status < 0) || unlikely(!netif_running(ndev))) { - bool ndev_status = false; - struct cpsw_slave *slave = cpsw->slaves; - int n; - - if (cpsw->data.dual_emac) { - /* In dual emac mode check for all interfaces */ - for (n = cpsw->data.slaves; n; n--, slave++) - if (netif_running(slave->ndev)) - ndev_status = true; - } - - if (ndev_status && (status >= 0)) { + /* In dual emac mode check for all interfaces */ + if (cpsw->data.dual_emac && + cpsw_get_usage_count(cpsw) && + (status >= 0)) { /* The packet received is for the interface which * is already down and the other interface is up * and running, instead of freeing which results @@ -1234,18 +1238,6 @@ static void cpsw_get_ethtool_stats(struct net_device *ndev, } } -static int cpsw_get_usage_count(struct cpsw_common *cpsw) -{ - u32 i; - u32 usage_count = 0; - - for (i = 0; i < cpsw->data.slaves; i++) - if (netif_running(cpsw->slaves[i].ndev)) - usage_count++; - - return usage_count; -} - static inline int cpsw_tx_packet_submit(struct cpsw_priv *priv, struct sk_buff *skb, struct cpdma_chan *txch)