Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1493581lqo; Sat, 18 May 2024 05:49:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWxo4vqWL2JQNvTw1tLbNscUb2wuyYcK38V/lrOmkpFBKVp11+jl0w8p4CESgUIBdwUf1ifJW1w1HbxoD1dPhkHt4jI3G3QJNbNfM59Tg== X-Google-Smtp-Source: AGHT+IFUG0JOZcQ1ywInQf/ygmSsH6YX9GoWbu8D/xfb5ajTDfNX/06sMl2G9vWWprbQhiHrpOxG X-Received: by 2002:a05:6214:5d8c:b0:6a0:b4fd:d0a0 with SMTP id 6a1803df08f44-6a168147ef0mr251372196d6.6.1716036558927; Sat, 18 May 2024 05:49:18 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f29ab8asi212753586d6.236.2024.05.18.05.49.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 05:49:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182868-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=fexKLyd8; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-182868-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182868-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A56E61C2100F for ; Sat, 18 May 2024 12:49:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35E727710C; Sat, 18 May 2024 12:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ti.com header.i=@ti.com header.b="fexKLyd8" Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (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 EEF55770FA; Sat, 18 May 2024 12:44:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716036281; cv=none; b=qQfgq1od/sQ+qujdaPmAY0RkoqpikRRB6Ry7oONVlBOEVWtTywjbFfYK0f9AC+gOUQq/5/dqAcZ7LM7LBR02cV4Vc4ahtufilTuVrIMVgaUSGU7g7rb/ezUWckHSdrp8URepgoQPqUXTwwdWp7+s70zpfH74FN0Ebs+AE6ybyW8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716036281; c=relaxed/simple; bh=TkZ8YCzGf3L4/woShJhNStGq6ph3UlMnPIzsSyhl65U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LLxtHjJwS/u923/lxbDxiYARoWKwzXdoXNqxCBBrk6nBVK7Apj6qLyuSMi0e1mDNjSTQ2Hakv99CubinPJin/6qCarBjnL0Kt57yBqs3VbGyRiLSCR8p+eZbkcYdd+Jk3HJtMZJQb7X6l8jCobffrR9g63+82rfQ/9EoNu2jjl8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=fexKLyd8; arc=none smtp.client-ip=198.47.23.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 44ICiK5o017356; Sat, 18 May 2024 07:44:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1716036260; bh=bhrgTDMVzI0dP8d/KQcIUJP6wdPok2F5QjLOlXwW5rY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=fexKLyd8OlzpsoOiCIHCWanAWn6FgEqgJxW9JEEkeDcJbDPxC7oMezMsQt4DoUe2M za+kMTvGs69pY1hUWwdwgvWDkykQ5rkjFX5HxjniZVIIHlih+qVSFb4vfZtceLmFsS sK9nu5OtJ9APr88pxlv4bhQ+IXeRgwZy1cUYHXSU= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 44ICiKAF130101 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 18 May 2024 07:44:20 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Sat, 18 May 2024 07:44:20 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Sat, 18 May 2024 07:44:20 -0500 Received: from uda0492258.dhcp.ti.com (uda0492258.dhcp.ti.com [172.24.227.9]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 44ICgY9c041511; Sat, 18 May 2024 07:44:16 -0500 From: Siddharth Vadapalli To: , , , , , , , CC: , , , , , , , Subject: [RFC PATCH net-next 22/28] net: ethernet: ti: cpsw-proxy-client: implement .get_link ethtool op Date: Sat, 18 May 2024 18:12:28 +0530 Message-ID: <20240518124234.2671651-23-s-vadapalli@ti.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240518124234.2671651-1-s-vadapalli@ti.com> References: <20240518124234.2671651-1-s-vadapalli@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Add the "vport_get_link()" function and register it as the driver's get_link ethtool_ops callback. Signed-off-by: Siddharth Vadapalli --- drivers/net/ethernet/ti/cpsw-proxy-client.c | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/net/ethernet/ti/cpsw-proxy-client.c b/drivers/net/ethernet/ti/cpsw-proxy-client.c index be42b02c3894..450fc183eaac 100644 --- a/drivers/net/ethernet/ti/cpsw-proxy-client.c +++ b/drivers/net/ethernet/ti/cpsw-proxy-client.c @@ -284,6 +284,7 @@ static int create_request_message(struct cpsw_proxy_req_params *req_params) case ETHFW_ALLOC_MAC: case ETHFW_VIRT_PORT_DETACH: case ETHFW_VIRT_PORT_INFO: + case ETHFW_VIRT_PORT_LINK_STATUS: common_req_msg = (struct common_request_message *)msg; req_msg_hdr = &common_req_msg->request_msg_hdr; break; @@ -1184,7 +1185,38 @@ static int vport_rx_poll(struct napi_struct *napi_rx, int budget) return num_rx; } +static u32 vport_get_link(struct net_device *ndev) +{ + struct virtual_port *vport = vport_ndev_to_vport(ndev); + struct cpsw_proxy_priv *proxy_priv = vport->proxy_priv; + struct port_link_status_response *pls_resp; + struct cpsw_proxy_req_params *req_p; + struct message resp_msg; + bool link_up; + int ret; + + if (vport->port_type != VIRT_MAC_ONLY_PORT) + return ethtool_op_get_link(ndev); + + mutex_lock(&proxy_priv->req_params_mutex); + req_p = &proxy_priv->req_params; + req_p->request_type = ETHFW_VIRT_PORT_LINK_STATUS; + req_p->token = vport->port_token; + ret = send_request_get_response(proxy_priv, &resp_msg); + mutex_unlock(&proxy_priv->req_params_mutex); + if (ret) { + netdev_err(ndev, "failed to get link status\n"); + /* Assume that link is down if status is unknown */ + return 0; + } + pls_resp = (struct port_link_status_response *)&resp_msg; + link_up = pls_resp->link_up; + + return link_up; +} + const struct ethtool_ops cpsw_proxy_client_ethtool_ops = { + .get_link = vport_get_link, }; static int register_mac(struct virtual_port *vport) -- 2.40.1