lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240518124234.2671651-23-s-vadapalli@ti.com>
Date: Sat, 18 May 2024 18:12:28 +0530
From: Siddharth Vadapalli <s-vadapalli@...com>
To: <davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
        <pabeni@...hat.com>, <corbet@....net>, <rogerq@...nel.org>,
        <danishanwar@...com>, <vladimir.oltean@....com>
CC: <netdev@...r.kernel.org>, <linux-doc@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <linux-arm-kernel@...ts.infradead.org>,
        <vigneshr@...com>, <misael.lopez@...com>, <srk@...com>,
        <s-vadapalli@...com>
Subject: [RFC PATCH net-next 22/28] net: ethernet: ti: cpsw-proxy-client: implement .get_link ethtool op

Add the "vport_get_link()" function and register it as the driver's
get_link ethtool_ops callback.

Signed-off-by: Siddharth Vadapalli <s-vadapalli@...com>
---
 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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ