[RFC PATCH net-next 15/28] net: ethernet: ti: cpsw-proxy-client: add helpers to (de)register MAC
Siddharth Vadapalli
s-vadapalli at ti.com
Sat May 18 05:42:21 PDT 2024
Add functions "register_mac()" and "deregister_mac()" to register and
deregister MAC Address of the network interface corresponding to the
Virtual Port with EthFw. Registering the MAC Address with EthFw is
necessary to receive unicast traffic directed to the MAC Address.
Signed-off-by: Siddharth Vadapalli <s-vadapalli at ti.com>
---
drivers/net/ethernet/ti/cpsw-proxy-client.c | 47 +++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/drivers/net/ethernet/ti/cpsw-proxy-client.c b/drivers/net/ethernet/ti/cpsw-proxy-client.c
index b0f0e5db3a74..7af4a89a1847 100644
--- a/drivers/net/ethernet/ti/cpsw-proxy-client.c
+++ b/drivers/net/ethernet/ti/cpsw-proxy-client.c
@@ -1182,6 +1182,53 @@ static int vport_rx_poll(struct napi_struct *napi_rx, int budget)
const struct ethtool_ops cpsw_proxy_client_ethtool_ops = {
};
+static int register_mac(struct virtual_port *vport)
+{
+ struct cpsw_proxy_priv *proxy_priv = vport->proxy_priv;
+ struct rx_dma_chan *rx_chn = &vport->rx_chans[0];
+ struct cpsw_proxy_req_params *req_p;
+ struct message resp_msg;
+ int ret;
+
+ /* Register MAC Address only for RX DMA Channel 0 */
+ mutex_lock(&proxy_priv->req_params_mutex);
+ req_p = &proxy_priv->req_params;
+ req_p->request_type = ETHFW_MAC_REGISTER;
+ req_p->token = vport->port_token;
+ req_p->rx_flow_base = rx_chn->flow_base;
+ req_p->rx_flow_offset = rx_chn->flow_offset;
+ ether_addr_copy(req_p->mac_addr, vport->mac_addr);
+ ret = send_request_get_response(proxy_priv, &resp_msg);
+ mutex_unlock(&proxy_priv->req_params_mutex);
+ if (ret)
+ dev_err(proxy_priv->dev, "failed to register MAC Address\n");
+
+ return ret;
+}
+
+static int deregister_mac(struct virtual_port *vport)
+{
+ struct cpsw_proxy_priv *proxy_priv = vport->proxy_priv;
+ struct rx_dma_chan *rx_chn = &vport->rx_chans[0];
+ struct cpsw_proxy_req_params *req_p;
+ struct message resp_msg;
+ int ret;
+
+ mutex_lock(&proxy_priv->req_params_mutex);
+ req_p = &proxy_priv->req_params;
+ req_p->request_type = ETHFW_MAC_DEREGISTER;
+ req_p->token = vport->port_token;
+ req_p->rx_flow_base = rx_chn->flow_base;
+ req_p->rx_flow_offset = rx_chn->flow_offset;
+ ether_addr_copy(req_p->mac_addr, vport->mac_addr);
+ ret = send_request_get_response(proxy_priv, &resp_msg);
+ mutex_unlock(&proxy_priv->req_params_mutex);
+ if (ret)
+ dev_err(proxy_priv->dev, "failed to deregister MAC Address\n");
+
+ return ret;
+}
+
static const struct net_device_ops cpsw_proxy_client_netdev_ops = {
};
--
2.40.1
More information about the linux-arm-kernel
mailing list