提交 e393fbd6 编写于 作者: J Jiantao Xiao

net: hns3: add support configuring function-level interrupt affinity

driver inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I6QRKC
CVE: NA

----------------------------------------------------------------------

The patch provides a customized interface for configuring the interrupt
affinity of the hns3 network port.
Signed-off-by: NJiantao Xiao <xiaojiantao1@h-partners.com>
上级 01e611e3
...@@ -214,3 +214,59 @@ int nic_clean_stats64(struct net_device *ndev, struct rtnl_link_stats64 *stats) ...@@ -214,3 +214,59 @@ int nic_clean_stats64(struct net_device *ndev, struct rtnl_link_stats64 *stats)
return ret; return ret;
} }
EXPORT_SYMBOL(nic_clean_stats64); EXPORT_SYMBOL(nic_clean_stats64);
int nic_set_cpu_affinity(struct net_device *ndev, cpumask_t *affinity_mask)
{
struct hns3_enet_tqp_vector *tqp_vector;
struct hns3_nic_priv *priv;
int ret = 0;
u16 i;
if (!ndev || !affinity_mask) {
netdev_err(ndev,
"Invalid input param when set ethernet cpu affinity\n");
return -EINVAL;
}
if (nic_netdev_match_check(ndev))
return -ENODEV;
priv = netdev_priv(ndev);
rtnl_lock();
if (!test_bit(HNS3_NIC_STATE_INITED, &priv->state) ||
test_bit(HNS3_NIC_STATE_RESETTING, &priv->state)) {
ret = -EBUSY;
goto err_unlock;
}
for (i = 0; i < priv->vector_num; i++) {
tqp_vector = &priv->tqp_vector[i];
if (tqp_vector->irq_init_flag != HNS3_VECTOR_INITED)
continue;
tqp_vector->affinity_mask = *affinity_mask;
ret = irq_set_affinity_hint(tqp_vector->vector_irq, NULL);
if (ret) {
netdev_err(ndev,
"failed to reset affinity hint, ret = %d\n", ret);
goto err_unlock;
}
ret = irq_set_affinity_hint(tqp_vector->vector_irq,
&tqp_vector->affinity_mask);
if (ret) {
netdev_err(ndev,
"failed to set affinity hint, ret = %d\n", ret);
goto err_unlock;
}
}
netdev_info(ndev, "set nic cpu affinity %*pb succeed\n",
cpumask_pr_args(affinity_mask));
err_unlock:
rtnl_unlock();
return ret;
}
EXPORT_SYMBOL(nic_set_cpu_affinity);
...@@ -27,4 +27,5 @@ int nic_set_notify_pkt_start(struct net_device *ndev); ...@@ -27,4 +27,5 @@ int nic_set_notify_pkt_start(struct net_device *ndev);
int nic_set_torus_param(struct net_device *ndev, struct hnae3_torus_param *param); int nic_set_torus_param(struct net_device *ndev, struct hnae3_torus_param *param);
int nic_get_torus_param(struct net_device *ndev, struct hnae3_torus_param *param); int nic_get_torus_param(struct net_device *ndev, struct hnae3_torus_param *param);
int nic_clean_stats64(struct net_device *ndev, struct rtnl_link_stats64 *stats); int nic_clean_stats64(struct net_device *ndev, struct rtnl_link_stats64 *stats);
int nic_set_cpu_affinity(struct net_device *ndev, cpumask_t *affinity_mask);
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册