Commit 1c3dc891 authored by David S. Miller's avatar David S. Miller

Merge branch 'hns3-cleanups'

Yunsheng Lin says:

====================
A few cleanup for hns3 ethernet driver

This patchset contains a few cleanup for hns3 ethernet driver.
No functional change intended.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents c49c777f 1db9b1bf
...@@ -208,7 +208,7 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num) ...@@ -208,7 +208,7 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num)
* which will be use for hardware to write back * which will be use for hardware to write back
*/ */
ntc = hw->cmq.csq.next_to_use; ntc = hw->cmq.csq.next_to_use;
opcode = desc[0].opcode; opcode = le16_to_cpu(desc[0].opcode);
while (handle < num) { while (handle < num) {
desc_to_use = &hw->cmq.csq.desc[hw->cmq.csq.next_to_use]; desc_to_use = &hw->cmq.csq.desc[hw->cmq.csq.next_to_use];
*desc_to_use = desc[handle]; *desc_to_use = desc[handle];
...@@ -225,7 +225,7 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num) ...@@ -225,7 +225,7 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num)
* If the command is sync, wait for the firmware to write back, * If the command is sync, wait for the firmware to write back,
* if multi descriptors to be sent, use the first one to check * if multi descriptors to be sent, use the first one to check
*/ */
if (HCLGE_SEND_SYNC(desc->flag)) { if (HCLGE_SEND_SYNC(le16_to_cpu(desc->flag))) {
do { do {
if (hclge_cmd_csq_done(hw)) if (hclge_cmd_csq_done(hw))
break; break;
...@@ -244,9 +244,9 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num) ...@@ -244,9 +244,9 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num)
pr_debug("Get cmd desc:\n"); pr_debug("Get cmd desc:\n");
if (likely(!hclge_is_special_opcode(opcode))) if (likely(!hclge_is_special_opcode(opcode)))
desc_ret = desc[handle].retval; desc_ret = le16_to_cpu(desc[handle].retval);
else else
desc_ret = desc[0].retval; desc_ret = le16_to_cpu(desc[0].retval);
if ((enum hclge_cmd_return_status)desc_ret == if ((enum hclge_cmd_return_status)desc_ret ==
HCLGE_CMD_EXEC_SUCCESS) HCLGE_CMD_EXEC_SUCCESS)
...@@ -276,15 +276,15 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num) ...@@ -276,15 +276,15 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num)
return retval; return retval;
} }
enum hclge_cmd_status hclge_cmd_query_firmware_version(struct hclge_hw *hw, static enum hclge_cmd_status hclge_cmd_query_firmware_version(
u32 *version) struct hclge_hw *hw, u32 *version)
{ {
struct hclge_query_version *resp; struct hclge_query_version_cmd *resp;
struct hclge_desc desc; struct hclge_desc desc;
int ret; int ret;
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_QUERY_FW_VER, 1); hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_QUERY_FW_VER, 1);
resp = (struct hclge_query_version *)desc.data; resp = (struct hclge_query_version_cmd *)desc.data;
ret = hclge_cmd_send(hw, &desc, 1); ret = hclge_cmd_send(hw, &desc, 1);
if (!ret) if (!ret)
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#define HCLGE_VECTOR_VF_OFFSET 0x100000 #define HCLGE_VECTOR_VF_OFFSET 0x100000
#define HCLGE_RSS_IND_TBL_SIZE 512 #define HCLGE_RSS_IND_TBL_SIZE 512
#define HCLGE_RSS_SET_BITMAP_MSK 0xffff #define HCLGE_RSS_SET_BITMAP_MSK GENMASK(15, 0)
#define HCLGE_RSS_KEY_SIZE 40 #define HCLGE_RSS_KEY_SIZE 40
#define HCLGE_RSS_HASH_ALGO_TOEPLITZ 0 #define HCLGE_RSS_HASH_ALGO_TOEPLITZ 0
#define HCLGE_RSS_HASH_ALGO_SIMPLE 1 #define HCLGE_RSS_HASH_ALGO_SIMPLE 1
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
#define HCLGE_PHY_CSS_REG 17 #define HCLGE_PHY_CSS_REG 17
#define HCLGE_PHY_MDIX_CTRL_S (5) #define HCLGE_PHY_MDIX_CTRL_S (5)
#define HCLGE_PHY_MDIX_CTRL_M (3 << HCLGE_PHY_MDIX_CTRL_S) #define HCLGE_PHY_MDIX_CTRL_M GENMASK(6, 5)
#define HCLGE_PHY_MDIX_STATUS_B (6) #define HCLGE_PHY_MDIX_STATUS_B (6)
#define HCLGE_PHY_SPEED_DUP_RESOLVE_B (11) #define HCLGE_PHY_SPEED_DUP_RESOLVE_B (11)
......
...@@ -283,6 +283,7 @@ static int hclge_tm_pg_shapping_cfg(struct hclge_dev *hdev, ...@@ -283,6 +283,7 @@ static int hclge_tm_pg_shapping_cfg(struct hclge_dev *hdev,
struct hclge_pg_shapping_cmd *shap_cfg_cmd; struct hclge_pg_shapping_cmd *shap_cfg_cmd;
enum hclge_opcode_type opcode; enum hclge_opcode_type opcode;
struct hclge_desc desc; struct hclge_desc desc;
u32 shapping_para = 0;
opcode = bucket ? HCLGE_OPC_TM_PG_P_SHAPPING : opcode = bucket ? HCLGE_OPC_TM_PG_P_SHAPPING :
HCLGE_OPC_TM_PG_C_SHAPPING; HCLGE_OPC_TM_PG_C_SHAPPING;
...@@ -292,11 +293,13 @@ static int hclge_tm_pg_shapping_cfg(struct hclge_dev *hdev, ...@@ -292,11 +293,13 @@ static int hclge_tm_pg_shapping_cfg(struct hclge_dev *hdev,
shap_cfg_cmd->pg_id = pg_id; shap_cfg_cmd->pg_id = pg_id;
hclge_tm_set_field(shap_cfg_cmd->pg_shapping_para, IR_B, ir_b); hclge_tm_set_field(shapping_para, IR_B, ir_b);
hclge_tm_set_field(shap_cfg_cmd->pg_shapping_para, IR_U, ir_u); hclge_tm_set_field(shapping_para, IR_U, ir_u);
hclge_tm_set_field(shap_cfg_cmd->pg_shapping_para, IR_S, ir_s); hclge_tm_set_field(shapping_para, IR_S, ir_s);
hclge_tm_set_field(shap_cfg_cmd->pg_shapping_para, BS_B, bs_b); hclge_tm_set_field(shapping_para, BS_B, bs_b);
hclge_tm_set_field(shap_cfg_cmd->pg_shapping_para, BS_S, bs_s); hclge_tm_set_field(shapping_para, BS_S, bs_s);
shap_cfg_cmd->pg_shapping_para = cpu_to_le32(shapping_para);
return hclge_cmd_send(&hdev->hw, &desc, 1); return hclge_cmd_send(&hdev->hw, &desc, 1);
} }
...@@ -337,6 +340,7 @@ static int hclge_tm_pri_shapping_cfg(struct hclge_dev *hdev, ...@@ -337,6 +340,7 @@ static int hclge_tm_pri_shapping_cfg(struct hclge_dev *hdev,
struct hclge_pri_shapping_cmd *shap_cfg_cmd; struct hclge_pri_shapping_cmd *shap_cfg_cmd;
enum hclge_opcode_type opcode; enum hclge_opcode_type opcode;
struct hclge_desc desc; struct hclge_desc desc;
u32 shapping_para = 0;
opcode = bucket ? HCLGE_OPC_TM_PRI_P_SHAPPING : opcode = bucket ? HCLGE_OPC_TM_PRI_P_SHAPPING :
HCLGE_OPC_TM_PRI_C_SHAPPING; HCLGE_OPC_TM_PRI_C_SHAPPING;
...@@ -347,11 +351,13 @@ static int hclge_tm_pri_shapping_cfg(struct hclge_dev *hdev, ...@@ -347,11 +351,13 @@ static int hclge_tm_pri_shapping_cfg(struct hclge_dev *hdev,
shap_cfg_cmd->pri_id = pri_id; shap_cfg_cmd->pri_id = pri_id;
hclge_tm_set_field(shap_cfg_cmd->pri_shapping_para, IR_B, ir_b); hclge_tm_set_field(shapping_para, IR_B, ir_b);
hclge_tm_set_field(shap_cfg_cmd->pri_shapping_para, IR_U, ir_u); hclge_tm_set_field(shapping_para, IR_U, ir_u);
hclge_tm_set_field(shap_cfg_cmd->pri_shapping_para, IR_S, ir_s); hclge_tm_set_field(shapping_para, IR_S, ir_s);
hclge_tm_set_field(shap_cfg_cmd->pri_shapping_para, BS_B, bs_b); hclge_tm_set_field(shapping_para, BS_B, bs_b);
hclge_tm_set_field(shap_cfg_cmd->pri_shapping_para, BS_S, bs_s); hclge_tm_set_field(shapping_para, BS_S, bs_s);
shap_cfg_cmd->pri_shapping_para = cpu_to_le32(shapping_para);
return hclge_cmd_send(&hdev->hw, &desc, 1); return hclge_cmd_send(&hdev->hw, &desc, 1);
} }
......
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
static static
int hns3_dcbnl_ieee_getets(struct net_device *ndev, struct ieee_ets *ets) int hns3_dcbnl_ieee_getets(struct net_device *ndev, struct ieee_ets *ets)
{ {
struct hns3_nic_priv *priv = netdev_priv(ndev); struct hnae3_handle *h = hns3_get_handle(ndev);
struct hnae3_handle *h = priv->ae_handle;
if (h->kinfo.dcb_ops->ieee_getets) if (h->kinfo.dcb_ops->ieee_getets)
return h->kinfo.dcb_ops->ieee_getets(h, ets); return h->kinfo.dcb_ops->ieee_getets(h, ets);
...@@ -25,8 +24,7 @@ int hns3_dcbnl_ieee_getets(struct net_device *ndev, struct ieee_ets *ets) ...@@ -25,8 +24,7 @@ int hns3_dcbnl_ieee_getets(struct net_device *ndev, struct ieee_ets *ets)
static static
int hns3_dcbnl_ieee_setets(struct net_device *ndev, struct ieee_ets *ets) int hns3_dcbnl_ieee_setets(struct net_device *ndev, struct ieee_ets *ets)
{ {
struct hns3_nic_priv *priv = netdev_priv(ndev); struct hnae3_handle *h = hns3_get_handle(ndev);
struct hnae3_handle *h = priv->ae_handle;
if (h->kinfo.dcb_ops->ieee_setets) if (h->kinfo.dcb_ops->ieee_setets)
return h->kinfo.dcb_ops->ieee_setets(h, ets); return h->kinfo.dcb_ops->ieee_setets(h, ets);
...@@ -37,8 +35,7 @@ int hns3_dcbnl_ieee_setets(struct net_device *ndev, struct ieee_ets *ets) ...@@ -37,8 +35,7 @@ int hns3_dcbnl_ieee_setets(struct net_device *ndev, struct ieee_ets *ets)
static static
int hns3_dcbnl_ieee_getpfc(struct net_device *ndev, struct ieee_pfc *pfc) int hns3_dcbnl_ieee_getpfc(struct net_device *ndev, struct ieee_pfc *pfc)
{ {
struct hns3_nic_priv *priv = netdev_priv(ndev); struct hnae3_handle *h = hns3_get_handle(ndev);
struct hnae3_handle *h = priv->ae_handle;
if (h->kinfo.dcb_ops->ieee_getpfc) if (h->kinfo.dcb_ops->ieee_getpfc)
return h->kinfo.dcb_ops->ieee_getpfc(h, pfc); return h->kinfo.dcb_ops->ieee_getpfc(h, pfc);
...@@ -49,8 +46,7 @@ int hns3_dcbnl_ieee_getpfc(struct net_device *ndev, struct ieee_pfc *pfc) ...@@ -49,8 +46,7 @@ int hns3_dcbnl_ieee_getpfc(struct net_device *ndev, struct ieee_pfc *pfc)
static static
int hns3_dcbnl_ieee_setpfc(struct net_device *ndev, struct ieee_pfc *pfc) int hns3_dcbnl_ieee_setpfc(struct net_device *ndev, struct ieee_pfc *pfc)
{ {
struct hns3_nic_priv *priv = netdev_priv(ndev); struct hnae3_handle *h = hns3_get_handle(ndev);
struct hnae3_handle *h = priv->ae_handle;
if (h->kinfo.dcb_ops->ieee_setpfc) if (h->kinfo.dcb_ops->ieee_setpfc)
return h->kinfo.dcb_ops->ieee_setpfc(h, pfc); return h->kinfo.dcb_ops->ieee_setpfc(h, pfc);
...@@ -61,8 +57,7 @@ int hns3_dcbnl_ieee_setpfc(struct net_device *ndev, struct ieee_pfc *pfc) ...@@ -61,8 +57,7 @@ int hns3_dcbnl_ieee_setpfc(struct net_device *ndev, struct ieee_pfc *pfc)
/* DCBX configuration */ /* DCBX configuration */
static u8 hns3_dcbnl_getdcbx(struct net_device *ndev) static u8 hns3_dcbnl_getdcbx(struct net_device *ndev)
{ {
struct hns3_nic_priv *priv = netdev_priv(ndev); struct hnae3_handle *h = hns3_get_handle(ndev);
struct hnae3_handle *h = priv->ae_handle;
if (h->kinfo.dcb_ops->getdcbx) if (h->kinfo.dcb_ops->getdcbx)
return h->kinfo.dcb_ops->getdcbx(h); return h->kinfo.dcb_ops->getdcbx(h);
...@@ -73,8 +68,7 @@ static u8 hns3_dcbnl_getdcbx(struct net_device *ndev) ...@@ -73,8 +68,7 @@ static u8 hns3_dcbnl_getdcbx(struct net_device *ndev)
/* return 0 if successful, otherwise fail */ /* return 0 if successful, otherwise fail */
static u8 hns3_dcbnl_setdcbx(struct net_device *ndev, u8 mode) static u8 hns3_dcbnl_setdcbx(struct net_device *ndev, u8 mode)
{ {
struct hns3_nic_priv *priv = netdev_priv(ndev); struct hnae3_handle *h = hns3_get_handle(ndev);
struct hnae3_handle *h = priv->ae_handle;
if (h->kinfo.dcb_ops->setdcbx) if (h->kinfo.dcb_ops->setdcbx)
return h->kinfo.dcb_ops->setdcbx(h, mode); return h->kinfo.dcb_ops->setdcbx(h, mode);
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "hnae3.h" #include "hnae3.h"
#include "hns3_enet.h" #include "hns3_enet.h"
const char hns3_driver_name[] = "hns3"; static const char hns3_driver_name[] = "hns3";
const char hns3_driver_version[] = VERMAGIC_STRING; const char hns3_driver_version[] = VERMAGIC_STRING;
static const char hns3_driver_string[] = static const char hns3_driver_string[] =
"Hisilicon Ethernet Network Driver for Hip08 Family"; "Hisilicon Ethernet Network Driver for Hip08 Family";
...@@ -198,8 +198,7 @@ static void hns3_vector_gl_rl_init(struct hns3_enet_tqp_vector *tqp_vector) ...@@ -198,8 +198,7 @@ static void hns3_vector_gl_rl_init(struct hns3_enet_tqp_vector *tqp_vector)
static int hns3_nic_set_real_num_queue(struct net_device *netdev) static int hns3_nic_set_real_num_queue(struct net_device *netdev)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
struct hnae3_knic_private_info *kinfo = &h->kinfo; struct hnae3_knic_private_info *kinfo = &h->kinfo;
unsigned int queue_size = kinfo->rss_size * kinfo->num_tc; unsigned int queue_size = kinfo->rss_size * kinfo->num_tc;
int ret; int ret;
...@@ -305,24 +304,10 @@ static int hns3_nic_net_stop(struct net_device *netdev) ...@@ -305,24 +304,10 @@ static int hns3_nic_net_stop(struct net_device *netdev)
return 0; return 0;
} }
void hns3_set_multicast_list(struct net_device *netdev)
{
struct hns3_nic_priv *priv = netdev_priv(netdev);
struct hnae3_handle *h = priv->ae_handle;
struct netdev_hw_addr *ha = NULL;
if (h->ae_algo->ops->set_mc_addr) {
netdev_for_each_mc_addr(ha, netdev)
if (h->ae_algo->ops->set_mc_addr(h, ha->addr))
netdev_err(netdev, "set multicast fail\n");
}
}
static int hns3_nic_uc_sync(struct net_device *netdev, static int hns3_nic_uc_sync(struct net_device *netdev,
const unsigned char *addr) const unsigned char *addr)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
if (h->ae_algo->ops->add_uc_addr) if (h->ae_algo->ops->add_uc_addr)
return h->ae_algo->ops->add_uc_addr(h, addr); return h->ae_algo->ops->add_uc_addr(h, addr);
...@@ -333,8 +318,7 @@ static int hns3_nic_uc_sync(struct net_device *netdev, ...@@ -333,8 +318,7 @@ static int hns3_nic_uc_sync(struct net_device *netdev,
static int hns3_nic_uc_unsync(struct net_device *netdev, static int hns3_nic_uc_unsync(struct net_device *netdev,
const unsigned char *addr) const unsigned char *addr)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
if (h->ae_algo->ops->rm_uc_addr) if (h->ae_algo->ops->rm_uc_addr)
return h->ae_algo->ops->rm_uc_addr(h, addr); return h->ae_algo->ops->rm_uc_addr(h, addr);
...@@ -345,8 +329,7 @@ static int hns3_nic_uc_unsync(struct net_device *netdev, ...@@ -345,8 +329,7 @@ static int hns3_nic_uc_unsync(struct net_device *netdev,
static int hns3_nic_mc_sync(struct net_device *netdev, static int hns3_nic_mc_sync(struct net_device *netdev,
const unsigned char *addr) const unsigned char *addr)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
if (h->ae_algo->ops->add_mc_addr) if (h->ae_algo->ops->add_mc_addr)
return h->ae_algo->ops->add_mc_addr(h, addr); return h->ae_algo->ops->add_mc_addr(h, addr);
...@@ -357,8 +340,7 @@ static int hns3_nic_mc_sync(struct net_device *netdev, ...@@ -357,8 +340,7 @@ static int hns3_nic_mc_sync(struct net_device *netdev,
static int hns3_nic_mc_unsync(struct net_device *netdev, static int hns3_nic_mc_unsync(struct net_device *netdev,
const unsigned char *addr) const unsigned char *addr)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
if (h->ae_algo->ops->rm_mc_addr) if (h->ae_algo->ops->rm_mc_addr)
return h->ae_algo->ops->rm_mc_addr(h, addr); return h->ae_algo->ops->rm_mc_addr(h, addr);
...@@ -366,10 +348,9 @@ static int hns3_nic_mc_unsync(struct net_device *netdev, ...@@ -366,10 +348,9 @@ static int hns3_nic_mc_unsync(struct net_device *netdev,
return 0; return 0;
} }
void hns3_nic_set_rx_mode(struct net_device *netdev) static void hns3_nic_set_rx_mode(struct net_device *netdev)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
if (h->ae_algo->ops->set_promisc_mode) { if (h->ae_algo->ops->set_promisc_mode) {
if (netdev->flags & IFF_PROMISC) if (netdev->flags & IFF_PROMISC)
...@@ -768,7 +749,7 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv, ...@@ -768,7 +749,7 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv,
if (type == DESC_TYPE_SKB) { if (type == DESC_TYPE_SKB) {
skb = (struct sk_buff *)priv; skb = (struct sk_buff *)priv;
paylen = cpu_to_le16(skb->len); paylen = skb->len;
if (skb->ip_summed == CHECKSUM_PARTIAL) { if (skb->ip_summed == CHECKSUM_PARTIAL) {
skb_reset_mac_len(skb); skb_reset_mac_len(skb);
...@@ -802,7 +783,7 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv, ...@@ -802,7 +783,7 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv,
cpu_to_le32(ol_type_vlan_len_msec); cpu_to_le32(ol_type_vlan_len_msec);
desc->tx.type_cs_vlan_tso_len = desc->tx.type_cs_vlan_tso_len =
cpu_to_le32(type_cs_vlan_tso); cpu_to_le32(type_cs_vlan_tso);
desc->tx.paylen = cpu_to_le16(paylen); desc->tx.paylen = cpu_to_le32(paylen);
desc->tx.mss = cpu_to_le16(mss); desc->tx.mss = cpu_to_le16(mss);
} }
...@@ -1025,8 +1006,7 @@ static netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, ...@@ -1025,8 +1006,7 @@ static netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb,
static int hns3_nic_net_set_mac_address(struct net_device *netdev, void *p) static int hns3_nic_net_set_mac_address(struct net_device *netdev, void *p)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
struct sockaddr *mac_addr = p; struct sockaddr *mac_addr = p;
int ret; int ret;
...@@ -1208,8 +1188,7 @@ static void hns3_nic_udp_tunnel_del(struct net_device *netdev, ...@@ -1208,8 +1188,7 @@ static void hns3_nic_udp_tunnel_del(struct net_device *netdev,
static int hns3_setup_tc(struct net_device *netdev, u8 tc) static int hns3_setup_tc(struct net_device *netdev, u8 tc)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
struct hnae3_knic_private_info *kinfo = &h->kinfo; struct hnae3_knic_private_info *kinfo = &h->kinfo;
unsigned int i; unsigned int i;
int ret; int ret;
...@@ -1259,8 +1238,7 @@ static int hns3_nic_setup_tc(struct net_device *dev, enum tc_setup_type type, ...@@ -1259,8 +1238,7 @@ static int hns3_nic_setup_tc(struct net_device *dev, enum tc_setup_type type,
static int hns3_vlan_rx_add_vid(struct net_device *netdev, static int hns3_vlan_rx_add_vid(struct net_device *netdev,
__be16 proto, u16 vid) __be16 proto, u16 vid)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
int ret = -EIO; int ret = -EIO;
if (h->ae_algo->ops->set_vlan_filter) if (h->ae_algo->ops->set_vlan_filter)
...@@ -1272,8 +1250,7 @@ static int hns3_vlan_rx_add_vid(struct net_device *netdev, ...@@ -1272,8 +1250,7 @@ static int hns3_vlan_rx_add_vid(struct net_device *netdev,
static int hns3_vlan_rx_kill_vid(struct net_device *netdev, static int hns3_vlan_rx_kill_vid(struct net_device *netdev,
__be16 proto, u16 vid) __be16 proto, u16 vid)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
int ret = -EIO; int ret = -EIO;
if (h->ae_algo->ops->set_vlan_filter) if (h->ae_algo->ops->set_vlan_filter)
...@@ -1285,8 +1262,7 @@ static int hns3_vlan_rx_kill_vid(struct net_device *netdev, ...@@ -1285,8 +1262,7 @@ static int hns3_vlan_rx_kill_vid(struct net_device *netdev,
static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan,
u8 qos, __be16 vlan_proto) u8 qos, __be16 vlan_proto)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
int ret = -EIO; int ret = -EIO;
if (h->ae_algo->ops->set_vf_vlan_filter) if (h->ae_algo->ops->set_vf_vlan_filter)
...@@ -1298,8 +1274,7 @@ static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, ...@@ -1298,8 +1274,7 @@ static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan,
static int hns3_nic_change_mtu(struct net_device *netdev, int new_mtu) static int hns3_nic_change_mtu(struct net_device *netdev, int new_mtu)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
bool if_running = netif_running(netdev); bool if_running = netif_running(netdev);
int ret; int ret;
...@@ -2609,7 +2584,7 @@ static void hns3_fini_ring(struct hns3_enet_ring *ring) ...@@ -2609,7 +2584,7 @@ static void hns3_fini_ring(struct hns3_enet_ring *ring)
ring->next_to_use = 0; ring->next_to_use = 0;
} }
int hns3_buf_size2type(u32 buf_size) static int hns3_buf_size2type(u32 buf_size)
{ {
int bd_size_type; int bd_size_type;
...@@ -2921,7 +2896,7 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc) ...@@ -2921,7 +2896,7 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc)
return ret; return ret;
} }
const struct hnae3_client_ops client_ops = { static const struct hnae3_client_ops client_ops = {
.init_instance = hns3_client_init, .init_instance = hns3_client_init,
.uninit_instance = hns3_client_uninit, .uninit_instance = hns3_client_uninit,
.link_status_change = hns3_link_status_change, .link_status_change = hns3_link_status_change,
......
...@@ -587,6 +587,9 @@ static inline void hns3_write_reg(void __iomem *base, u32 reg, u32 value) ...@@ -587,6 +587,9 @@ static inline void hns3_write_reg(void __iomem *base, u32 reg, u32 value)
#define hns3_for_each_ring(pos, head) \ #define hns3_for_each_ring(pos, head) \
for (pos = (head).ring; pos; pos = pos->next) for (pos = (head).ring; pos; pos = pos->next)
#define hns3_get_handle(ndev) \
(((struct hns3_nic_priv *)netdev_priv(ndev))->ae_handle)
void hns3_ethtool_set_ops(struct net_device *netdev); void hns3_ethtool_set_ops(struct net_device *netdev);
int hns3_clean_tx_ring(struct hns3_enet_ring *ring, int budget); int hns3_clean_tx_ring(struct hns3_enet_ring *ring, int budget);
......
...@@ -102,8 +102,7 @@ static void hns3_driv_to_eth_caps(u32 caps, struct ethtool_link_ksettings *cmd, ...@@ -102,8 +102,7 @@ static void hns3_driv_to_eth_caps(u32 caps, struct ethtool_link_ksettings *cmd,
static int hns3_get_sset_count(struct net_device *netdev, int stringset) static int hns3_get_sset_count(struct net_device *netdev, int stringset)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
const struct hnae3_ae_ops *ops = h->ae_algo->ops; const struct hnae3_ae_ops *ops = h->ae_algo->ops;
if (!ops->get_sset_count) if (!ops->get_sset_count)
...@@ -164,8 +163,7 @@ static u8 *hns3_get_strings_tqps(struct hnae3_handle *handle, u8 *data) ...@@ -164,8 +163,7 @@ static u8 *hns3_get_strings_tqps(struct hnae3_handle *handle, u8 *data)
static void hns3_get_strings(struct net_device *netdev, u32 stringset, u8 *data) static void hns3_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
const struct hnae3_ae_ops *ops = h->ae_algo->ops; const struct hnae3_ae_ops *ops = h->ae_algo->ops;
char *buff = (char *)data; char *buff = (char *)data;
...@@ -217,11 +215,10 @@ static u64 *hns3_get_stats_tqps(struct hnae3_handle *handle, u64 *data) ...@@ -217,11 +215,10 @@ static u64 *hns3_get_stats_tqps(struct hnae3_handle *handle, u64 *data)
* @stats: statistics info. * @stats: statistics info.
* @data: statistics data. * @data: statistics data.
*/ */
void hns3_get_stats(struct net_device *netdev, struct ethtool_stats *stats, static void hns3_get_stats(struct net_device *netdev,
u64 *data) struct ethtool_stats *stats, u64 *data)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
u64 *p = data; u64 *p = data;
if (!h->ae_algo->ops->get_stats || !h->ae_algo->ops->update_stats) { if (!h->ae_algo->ops->get_stats || !h->ae_algo->ops->update_stats) {
...@@ -262,10 +259,7 @@ static void hns3_get_drvinfo(struct net_device *netdev, ...@@ -262,10 +259,7 @@ static void hns3_get_drvinfo(struct net_device *netdev,
static u32 hns3_get_link(struct net_device *netdev) static u32 hns3_get_link(struct net_device *netdev)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h;
h = priv->ae_handle;
if (h->ae_algo && h->ae_algo->ops && h->ae_algo->ops->get_status) if (h->ae_algo && h->ae_algo->ops && h->ae_algo->ops->get_status)
return h->ae_algo->ops->get_status(h); return h->ae_algo->ops->get_status(h);
...@@ -277,7 +271,8 @@ static void hns3_get_ringparam(struct net_device *netdev, ...@@ -277,7 +271,8 @@ static void hns3_get_ringparam(struct net_device *netdev,
struct ethtool_ringparam *param) struct ethtool_ringparam *param)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hns3_nic_priv *priv = netdev_priv(netdev);
int queue_num = priv->ae_handle->kinfo.num_tqps; struct hnae3_handle *h = priv->ae_handle;
int queue_num = h->kinfo.num_tqps;
param->tx_max_pending = HNS3_RING_MAX_PENDING; param->tx_max_pending = HNS3_RING_MAX_PENDING;
param->rx_max_pending = HNS3_RING_MAX_PENDING; param->rx_max_pending = HNS3_RING_MAX_PENDING;
...@@ -289,8 +284,7 @@ static void hns3_get_ringparam(struct net_device *netdev, ...@@ -289,8 +284,7 @@ static void hns3_get_ringparam(struct net_device *netdev,
static void hns3_get_pauseparam(struct net_device *netdev, static void hns3_get_pauseparam(struct net_device *netdev,
struct ethtool_pauseparam *param) struct ethtool_pauseparam *param)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
if (h->ae_algo && h->ae_algo->ops && h->ae_algo->ops->get_pauseparam) if (h->ae_algo && h->ae_algo->ops && h->ae_algo->ops->get_pauseparam)
h->ae_algo->ops->get_pauseparam(h, &param->autoneg, h->ae_algo->ops->get_pauseparam(h, &param->autoneg,
...@@ -300,8 +294,7 @@ static void hns3_get_pauseparam(struct net_device *netdev, ...@@ -300,8 +294,7 @@ static void hns3_get_pauseparam(struct net_device *netdev,
static int hns3_get_link_ksettings(struct net_device *netdev, static int hns3_get_link_ksettings(struct net_device *netdev,
struct ethtool_link_ksettings *cmd) struct ethtool_link_ksettings *cmd)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
u32 supported_caps; u32 supported_caps;
u32 advertised_caps; u32 advertised_caps;
u8 media_type = HNAE3_MEDIA_TYPE_UNKNOWN; u8 media_type = HNAE3_MEDIA_TYPE_UNKNOWN;
...@@ -392,8 +385,7 @@ static int hns3_get_link_ksettings(struct net_device *netdev, ...@@ -392,8 +385,7 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
static u32 hns3_get_rss_key_size(struct net_device *netdev) static u32 hns3_get_rss_key_size(struct net_device *netdev)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
if (!h->ae_algo || !h->ae_algo->ops || if (!h->ae_algo || !h->ae_algo->ops ||
!h->ae_algo->ops->get_rss_key_size) !h->ae_algo->ops->get_rss_key_size)
...@@ -404,8 +396,7 @@ static u32 hns3_get_rss_key_size(struct net_device *netdev) ...@@ -404,8 +396,7 @@ static u32 hns3_get_rss_key_size(struct net_device *netdev)
static u32 hns3_get_rss_indir_size(struct net_device *netdev) static u32 hns3_get_rss_indir_size(struct net_device *netdev)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
if (!h->ae_algo || !h->ae_algo->ops || if (!h->ae_algo || !h->ae_algo->ops ||
!h->ae_algo->ops->get_rss_indir_size) !h->ae_algo->ops->get_rss_indir_size)
...@@ -417,8 +408,7 @@ static u32 hns3_get_rss_indir_size(struct net_device *netdev) ...@@ -417,8 +408,7 @@ static u32 hns3_get_rss_indir_size(struct net_device *netdev)
static int hns3_get_rss(struct net_device *netdev, u32 *indir, u8 *key, static int hns3_get_rss(struct net_device *netdev, u32 *indir, u8 *key,
u8 *hfunc) u8 *hfunc)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
if (!h->ae_algo || !h->ae_algo->ops || !h->ae_algo->ops->get_rss) if (!h->ae_algo || !h->ae_algo->ops || !h->ae_algo->ops->get_rss)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -429,8 +419,7 @@ static int hns3_get_rss(struct net_device *netdev, u32 *indir, u8 *key, ...@@ -429,8 +419,7 @@ static int hns3_get_rss(struct net_device *netdev, u32 *indir, u8 *key,
static int hns3_set_rss(struct net_device *netdev, const u32 *indir, static int hns3_set_rss(struct net_device *netdev, const u32 *indir,
const u8 *key, const u8 hfunc) const u8 *key, const u8 hfunc)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
if (!h->ae_algo || !h->ae_algo->ops || !h->ae_algo->ops->set_rss) if (!h->ae_algo || !h->ae_algo->ops || !h->ae_algo->ops->set_rss)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -454,8 +443,7 @@ static int hns3_get_rxnfc(struct net_device *netdev, ...@@ -454,8 +443,7 @@ static int hns3_get_rxnfc(struct net_device *netdev,
struct ethtool_rxnfc *cmd, struct ethtool_rxnfc *cmd,
u32 *rule_locs) u32 *rule_locs)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_handle *h = priv->ae_handle;
if (!h->ae_algo || !h->ae_algo->ops || !h->ae_algo->ops->get_tc_size) if (!h->ae_algo || !h->ae_algo->ops || !h->ae_algo->ops->get_tc_size)
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment