From patchwork Mon Jan 8 12:42:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 185973 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp993861dyq; Mon, 8 Jan 2024 04:48:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFw0SZGta+Er9qUlbHSRQJiRclzYs8PM23fXXQYpSF9FoRbZL3DsY6ZrGTr5fRHVfOG1/Zy X-Received: by 2002:a50:c11a:0:b0:557:e4c7:4a31 with SMTP id l26-20020a50c11a000000b00557e4c74a31mr32342edf.51.1704718106589; Mon, 08 Jan 2024 04:48:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704718106; cv=none; d=google.com; s=arc-20160816; b=wic1t/XTLn7Q3PqgziQqWXU7LADBdkdKlVtLITbkqMHbftXcoN5frx5W+2f/6uN9yZ MMhPfmhvBarLiWNGKbP89JHta2G80kcIHTXU9AUDZYQ4zFaEN2ihJy10A8Y+M2ioDbjR Bvmh8EYGzy5U/dPAzXazKk4Ud0l+Z+KFEw0Ej8bQnGAjozkfFmE3mD2o8eoVNxIkWDxi MxI89Rj7LfQLKwxzPZerVV0L769onNOrHllxgtLooh/ghVEBlKT+e1pOm+Z42YPnd/b2 dxYxJgMQAfR0CxTIOB6Yau2gu/fHk/Vgt/3wmBpLPNBLKx0c3pS9KFF2FXamlUPK8sJ4 dQPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fUPBaTQEH5fMC+HGD6Qp6fpaMk8RgrodZiZreQWQGdg=; fh=Y/Zcr0YXYeEsWchgSSogMl8sJJcf/EqHGWMcPJ+i19E=; b=gOvIjXhJ0zsoVr8hECheiaipI4kd3ZH9SJURvedqjgny82XoWmrV2tOROh82+7fAwa f8uYbYT5q2FG6ueKmbzQlo0nznd0kCeQISULOFeV+UCkKD2L5h6fSkSeQGkuYn3eh0hD UgUPwrZ29ZSbdhAkuoHXtwEyoRU8Y+wR2oAfy60olOzIg3b/HlTqnIF+wh9ERljlxgre aZMuwJdnSpVN7n3zErpYxh3HeHEksmFGg5X0RpB5rMxEbiZGPmSuEDhWfGMmA2a+nfSb ntNXo9B1syn278ShYfZl8C6dsfT/Kl+JWTlyIBLqQ9pQNj0RDmpnW4GR47pxEY45smX6 LzqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=XxxqFpwo; spf=pass (google.com: domain of linux-kernel+bounces-19559-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19559-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q17-20020a50c351000000b00553bfa1dee0si3025212edb.64.2024.01.08.04.48.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 04:48:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19559-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=XxxqFpwo; spf=pass (google.com: domain of linux-kernel+bounces-19559-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19559-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 342781F21C45 for ; Mon, 8 Jan 2024 12:48:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B89FD52F8C; Mon, 8 Jan 2024 12:42:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="XxxqFpwo" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B767551C4D; Mon, 8 Jan 2024 12:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 407NP5Zo009772; Mon, 8 Jan 2024 04:42:42 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= pfpt0220; bh=fUPBaTQEH5fMC+HGD6Qp6fpaMk8RgrodZiZreQWQGdg=; b=Xxx qFpwoa+fsAZUfi3As+B+aG2+5LMcJPeSYI6ZRh1mBzsAg7dIjvUjp0+F/AQGsMRb cfuqsm9JKJYyGN9aX6sEYaVVSWkoHiOwzr5S8pWYsJCWxr9HSHRezuXvutAySipK fMJXWxugJPWPcl2S5hFHalkKeM9Y/4MQgr8FMi2MPxB9hRSbDei9qWw9xLvICDjh IEPKcJD9s1QgeGIUmVc6ZramF0jIeFJc/UKKpytXwzHfq2nTza80O4zmZdy+Orwl 9acUZUBkyEaILuCHC/EBDbRKTVzqxHYccxnKuRiaqmjrS+W5JRR4NwwNHctedev5 6YftaK3W2IP5JH82Vfg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3vf78n4tn5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 08 Jan 2024 04:42:42 -0800 (PST) Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 8 Jan 2024 04:42:40 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Mon, 8 Jan 2024 04:42:40 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 38F0C3F7072; Mon, 8 Jan 2024 04:42:40 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , , , , Veerasenareddy Burru , Satananda Burla , "David S. Miller" , Eric Dumazet Subject: [PATCH net-next v4 5/8] octeon_ep_vf: add support for ndo ops Date: Mon, 8 Jan 2024 04:42:10 -0800 Message-ID: <20240108124213.2966536-6-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240108124213.2966536-1-srasheed@marvell.com> References: <20240108124213.2966536-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: -BxPvUqOjDlWSkXHK-GBexAvRT20DAaj X-Proofpoint-GUID: -BxPvUqOjDlWSkXHK-GBexAvRT20DAaj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787526493369377765 X-GMAIL-MSGID: 1787526493369377765 Add support for ndo ops to set MAC address, change MTU, get stats. Add control path support to set MAC address, change MTU, get stats, set speed, get and set link mode. Signed-off-by: Shinas Rasheed --- V4: - Provide more stats in ndo_get_stats64 such as tx_dropped, rx_dropped etc. V3: https://lore.kernel.org/all/20240105203823.2953604-6-srasheed@marvell.com/ - No changes V2: https://lore.kernel.org/all/20231223134000.2906144-6-srasheed@marvell.com/ - No changes V1: https://lore.kernel.org/all/20231221092844.2885872-6-srasheed@marvell.com/ .../marvell/octeon_ep_vf/octep_vf_main.c | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c index 51f92c8223e8..13084cac9ce0 100644 --- a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c @@ -187,6 +187,23 @@ static netdev_tx_t octep_vf_start_xmit(struct sk_buff *skb, return NETDEV_TX_OK; } +int octep_vf_get_if_stats(struct octep_vf_device *oct) +{ + struct octep_vf_iface_rxtx_stats vf_stats; + int ret, size; + + memset(&vf_stats, 0, sizeof(struct octep_vf_iface_rxtx_stats)); + ret = octep_vf_mbox_bulk_read(oct, OCTEP_PFVF_MBOX_CMD_GET_STATS, + (u8 *)&vf_stats, &size); + if (!ret) { + memcpy(&oct->iface_rx_stats, &vf_stats.iface_rx_stats, + sizeof(struct octep_vf_iface_rx_stats)); + memcpy(&oct->iface_tx_stats, &vf_stats.iface_tx_stats, + sizeof(struct octep_vf_iface_tx_stats)); + } + return ret; +} + int octep_vf_get_link_info(struct octep_vf_device *oct) { int ret, size; @@ -200,6 +217,46 @@ int octep_vf_get_link_info(struct octep_vf_device *oct) return 0; } +/** + * octep_vf_get_stats64() - Get Octeon network device statistics. + * + * @netdev: kernel network device. + * @stats: pointer to stats structure to be filled in. + */ +static void octep_vf_get_stats64(struct net_device *netdev, + struct rtnl_link_stats64 *stats) +{ + struct octep_vf_device *oct = netdev_priv(netdev); + u64 tx_packets, tx_bytes, rx_packets, rx_bytes; + int q; + + tx_packets = 0; + tx_bytes = 0; + rx_packets = 0; + rx_bytes = 0; + for (q = 0; q < oct->num_oqs; q++) { + struct octep_vf_iq *iq = oct->iq[q]; + struct octep_vf_oq *oq = oct->oq[q]; + + tx_packets += iq->stats.instr_completed; + tx_bytes += iq->stats.bytes_sent; + rx_packets += oq->stats.packets; + rx_bytes += oq->stats.bytes; + } + stats->tx_packets = tx_packets; + stats->tx_bytes = tx_bytes; + stats->rx_packets = rx_packets; + stats->rx_bytes = rx_bytes; + if (!octep_vf_get_if_stats(oct)) { + stats->multicast = oct->iface_rx_stats.mcast_pkts; + stats->rx_errors = oct->iface_rx_stats.err_pkts; + stats->rx_dropped = oct->iface_rx_stats.dropped_pkts_fifo_full + + oct->iface_rx_stats.err_pkts; + stats->rx_missed_errors = oct->iface_rx_stats.dropped_pkts_fifo_full; + stats->tx_dropped = oct->iface_tx_stats.dropped; + } +} + /** * octep_vf_tx_timeout_task - work queue task to Handle Tx queue timeout. * @@ -312,6 +369,7 @@ static const struct net_device_ops octep_vf_netdev_ops = { .ndo_open = octep_vf_open, .ndo_stop = octep_vf_stop, .ndo_start_xmit = octep_vf_start_xmit, + .ndo_get_stats64 = octep_vf_get_stats64, .ndo_tx_timeout = octep_vf_tx_timeout, .ndo_set_mac_address = octep_vf_set_mac, .ndo_change_mtu = octep_vf_change_mtu,