Commit caf337bd authored by David S. Miller's avatar David S. Miller

Merge branch 'code-optimizations-and-bugfixes-for-HNS3-driver'

Huazhong Tan says:

====================
code optimizations & bugfixes for HNS3 driver

This patchset includes bugfixes and code optimizations for
the HNS3 ethernet controller driver.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 834f9b05 18655128
...@@ -21,6 +21,7 @@ enum HCLGE_MBX_OPCODE { ...@@ -21,6 +21,7 @@ enum HCLGE_MBX_OPCODE {
HCLGE_MBX_SET_MACVLAN, /* (VF -> PF) set unicast filter */ HCLGE_MBX_SET_MACVLAN, /* (VF -> PF) set unicast filter */
HCLGE_MBX_API_NEGOTIATE, /* (VF -> PF) negotiate API version */ HCLGE_MBX_API_NEGOTIATE, /* (VF -> PF) negotiate API version */
HCLGE_MBX_GET_QINFO, /* (VF -> PF) get queue config */ HCLGE_MBX_GET_QINFO, /* (VF -> PF) get queue config */
HCLGE_MBX_GET_QDEPTH, /* (VF -> PF) get queue depth */
HCLGE_MBX_GET_TCINFO, /* (VF -> PF) get TC config */ HCLGE_MBX_GET_TCINFO, /* (VF -> PF) get TC config */
HCLGE_MBX_GET_RETA, /* (VF -> PF) get RETA */ HCLGE_MBX_GET_RETA, /* (VF -> PF) get RETA */
HCLGE_MBX_GET_RSS_KEY, /* (VF -> PF) get RSS key */ HCLGE_MBX_GET_RSS_KEY, /* (VF -> PF) get RSS key */
......
...@@ -87,7 +87,8 @@ struct hnae3_queue { ...@@ -87,7 +87,8 @@ struct hnae3_queue {
struct hnae3_handle *handle; struct hnae3_handle *handle;
int tqp_index; /* index in a handle */ int tqp_index; /* index in a handle */
u32 buf_size; /* size for hnae_desc->addr, preset by AE */ u32 buf_size; /* size for hnae_desc->addr, preset by AE */
u16 desc_num; /* total number of desc */ u16 tx_desc_num;/* total number of tx desc */
u16 rx_desc_num;/* total number of rx desc */
}; };
/*hnae3 loop mode*/ /*hnae3 loop mode*/
...@@ -505,7 +506,8 @@ struct hnae3_knic_private_info { ...@@ -505,7 +506,8 @@ struct hnae3_knic_private_info {
u16 rss_size; /* Allocated RSS queues */ u16 rss_size; /* Allocated RSS queues */
u16 req_rss_size; u16 req_rss_size;
u16 rx_buf_len; u16 rx_buf_len;
u16 num_desc; u16 num_tx_desc;
u16 num_rx_desc;
u8 num_tc; /* Total number of enabled TCs */ u8 num_tc; /* Total number of enabled TCs */
u8 prio_tc[HNAE3_MAX_USER_PRIO]; /* TC indexed by prio */ u8 prio_tc[HNAE3_MAX_USER_PRIO]; /* TC indexed by prio */
...@@ -537,7 +539,9 @@ struct hnae3_roce_private_info { ...@@ -537,7 +539,9 @@ struct hnae3_roce_private_info {
struct hnae3_unic_private_info { struct hnae3_unic_private_info {
struct net_device *netdev; struct net_device *netdev;
u16 rx_buf_len; u16 rx_buf_len;
u16 num_desc; u16 num_tx_desc;
u16 num_rx_desc;
u16 num_tqps; /* total number of tqps in this handle */ u16 num_tqps; /* total number of tqps in this handle */
struct hnae3_queue **tqp; /* array base of all TQPs of this instance */ struct hnae3_queue **tqp; /* array base of all TQPs of this instance */
}; };
......
...@@ -74,7 +74,7 @@ enum hns3_nic_state { ...@@ -74,7 +74,7 @@ enum hns3_nic_state {
#define HNS3_RING_NAME_LEN 16 #define HNS3_RING_NAME_LEN 16
#define HNS3_BUFFER_SIZE_2048 2048 #define HNS3_BUFFER_SIZE_2048 2048
#define HNS3_RING_MAX_PENDING 32768 #define HNS3_RING_MAX_PENDING 32768
#define HNS3_RING_MIN_PENDING 8 #define HNS3_RING_MIN_PENDING 24
#define HNS3_RING_BD_MULTIPLE 8 #define HNS3_RING_BD_MULTIPLE 8
/* max frame size of mac */ /* max frame size of mac */
#define HNS3_MAC_MAX_FRAME 9728 #define HNS3_MAC_MAX_FRAME 9728
...@@ -184,6 +184,8 @@ enum hns3_nic_state { ...@@ -184,6 +184,8 @@ enum hns3_nic_state {
#define HNS3_TXD_MSS_S 0 #define HNS3_TXD_MSS_S 0
#define HNS3_TXD_MSS_M (0x3fff << HNS3_TXD_MSS_S) #define HNS3_TXD_MSS_M (0x3fff << HNS3_TXD_MSS_S)
#define HNS3_TX_LAST_SIZE_M 0xffff
#define HNS3_VECTOR_TX_IRQ BIT_ULL(0) #define HNS3_VECTOR_TX_IRQ BIT_ULL(0)
#define HNS3_VECTOR_RX_IRQ BIT_ULL(1) #define HNS3_VECTOR_RX_IRQ BIT_ULL(1)
...@@ -191,6 +193,7 @@ enum hns3_nic_state { ...@@ -191,6 +193,7 @@ enum hns3_nic_state {
#define HNS3_VECTOR_INITED 1 #define HNS3_VECTOR_INITED 1
#define HNS3_MAX_BD_SIZE 65535 #define HNS3_MAX_BD_SIZE 65535
#define HNS3_MAX_BD_SIZE_OFFSET 16
#define HNS3_MAX_BD_PER_FRAG 8 #define HNS3_MAX_BD_PER_FRAG 8
#define HNS3_MAX_BD_PER_PKT MAX_SKB_FRAGS #define HNS3_MAX_BD_PER_PKT MAX_SKB_FRAGS
...@@ -441,11 +444,8 @@ struct hns3_nic_ring_data { ...@@ -441,11 +444,8 @@ struct hns3_nic_ring_data {
}; };
struct hns3_nic_ops { struct hns3_nic_ops {
int (*fill_desc)(struct hns3_enet_ring *ring, void *priv,
int size, int frag_end, enum hns_desc_type type);
int (*maybe_stop_tx)(struct sk_buff **out_skb, int (*maybe_stop_tx)(struct sk_buff **out_skb,
int *bnum, struct hns3_enet_ring *ring); int *bnum, struct hns3_enet_ring *ring);
void (*get_rxd_bnum)(u32 bnum_flag, int *out_bnum);
}; };
enum hns3_flow_level_range { enum hns3_flow_level_range {
......
...@@ -748,15 +748,19 @@ static int hns3_get_rxnfc(struct net_device *netdev, ...@@ -748,15 +748,19 @@ static int hns3_get_rxnfc(struct net_device *netdev,
} }
static int hns3_change_all_ring_bd_num(struct hns3_nic_priv *priv, static int hns3_change_all_ring_bd_num(struct hns3_nic_priv *priv,
u32 new_desc_num) u32 tx_desc_num, u32 rx_desc_num)
{ {
struct hnae3_handle *h = priv->ae_handle; struct hnae3_handle *h = priv->ae_handle;
int i; int i;
h->kinfo.num_desc = new_desc_num; h->kinfo.num_tx_desc = tx_desc_num;
h->kinfo.num_rx_desc = rx_desc_num;
for (i = 0; i < h->kinfo.num_tqps * 2; i++) for (i = 0; i < h->kinfo.num_tqps; i++) {
priv->ring_data[i].ring->desc_num = new_desc_num; priv->ring_data[i].ring->desc_num = tx_desc_num;
priv->ring_data[i + h->kinfo.num_tqps].ring->desc_num =
rx_desc_num;
}
return hns3_init_all_ring(priv); return hns3_init_all_ring(priv);
} }
...@@ -767,7 +771,9 @@ static int hns3_set_ringparam(struct net_device *ndev, ...@@ -767,7 +771,9 @@ static int hns3_set_ringparam(struct net_device *ndev,
struct hns3_nic_priv *priv = netdev_priv(ndev); struct hns3_nic_priv *priv = netdev_priv(ndev);
struct hnae3_handle *h = priv->ae_handle; struct hnae3_handle *h = priv->ae_handle;
bool if_running = netif_running(ndev); bool if_running = netif_running(ndev);
u32 old_desc_num, new_desc_num; u32 old_tx_desc_num, new_tx_desc_num;
u32 old_rx_desc_num, new_rx_desc_num;
int queue_num = h->kinfo.num_tqps;
int ret; int ret;
if (hns3_nic_resetting(ndev)) if (hns3_nic_resetting(ndev))
...@@ -776,32 +782,28 @@ static int hns3_set_ringparam(struct net_device *ndev, ...@@ -776,32 +782,28 @@ static int hns3_set_ringparam(struct net_device *ndev,
if (param->rx_mini_pending || param->rx_jumbo_pending) if (param->rx_mini_pending || param->rx_jumbo_pending)
return -EINVAL; return -EINVAL;
if (param->tx_pending != param->rx_pending) {
netdev_err(ndev,
"Descriptors of tx and rx must be equal");
return -EINVAL;
}
if (param->tx_pending > HNS3_RING_MAX_PENDING || if (param->tx_pending > HNS3_RING_MAX_PENDING ||
param->tx_pending < HNS3_RING_MIN_PENDING) { param->tx_pending < HNS3_RING_MIN_PENDING ||
netdev_err(ndev, param->rx_pending > HNS3_RING_MAX_PENDING ||
"Descriptors requested (Tx/Rx: %d) out of range [%d-%d]\n", param->rx_pending < HNS3_RING_MIN_PENDING) {
param->tx_pending, HNS3_RING_MIN_PENDING, netdev_err(ndev, "Queue depth out of range [%d-%d]\n",
HNS3_RING_MAX_PENDING); HNS3_RING_MIN_PENDING, HNS3_RING_MAX_PENDING);
return -EINVAL; return -EINVAL;
} }
new_desc_num = param->tx_pending;
/* Hardware requires that its descriptors must be multiple of eight */ /* Hardware requires that its descriptors must be multiple of eight */
new_desc_num = ALIGN(new_desc_num, HNS3_RING_BD_MULTIPLE); new_tx_desc_num = ALIGN(param->tx_pending, HNS3_RING_BD_MULTIPLE);
old_desc_num = h->kinfo.num_desc; new_rx_desc_num = ALIGN(param->rx_pending, HNS3_RING_BD_MULTIPLE);
if (old_desc_num == new_desc_num) old_tx_desc_num = priv->ring_data[0].ring->desc_num;
old_rx_desc_num = priv->ring_data[queue_num].ring->desc_num;
if (old_tx_desc_num == new_tx_desc_num &&
old_rx_desc_num == new_rx_desc_num)
return 0; return 0;
netdev_info(ndev, netdev_info(ndev,
"Changing descriptor count from %d to %d.\n", "Changing Tx/Rx ring depth from %d/%d to %d/%d\n",
old_desc_num, new_desc_num); old_tx_desc_num, old_rx_desc_num,
new_tx_desc_num, new_rx_desc_num);
if (if_running) if (if_running)
ndev->netdev_ops->ndo_stop(ndev); ndev->netdev_ops->ndo_stop(ndev);
...@@ -810,9 +812,11 @@ static int hns3_set_ringparam(struct net_device *ndev, ...@@ -810,9 +812,11 @@ static int hns3_set_ringparam(struct net_device *ndev,
if (ret) if (ret)
return ret; return ret;
ret = hns3_change_all_ring_bd_num(priv, new_desc_num); ret = hns3_change_all_ring_bd_num(priv, new_tx_desc_num,
new_rx_desc_num);
if (ret) { if (ret) {
ret = hns3_change_all_ring_bd_num(priv, old_desc_num); ret = hns3_change_all_ring_bd_num(priv, old_tx_desc_num,
old_rx_desc_num);
if (ret) { if (ret) {
netdev_err(ndev, netdev_err(ndev,
"Revert to old bd num fail, ret=%d.\n", ret); "Revert to old bd num fail, ret=%d.\n", ret);
......
...@@ -693,7 +693,9 @@ struct hclge_mac_vlan_remove_cmd { ...@@ -693,7 +693,9 @@ struct hclge_mac_vlan_remove_cmd {
struct hclge_vlan_filter_ctrl_cmd { struct hclge_vlan_filter_ctrl_cmd {
u8 vlan_type; u8 vlan_type;
u8 vlan_fe; u8 vlan_fe;
u8 rsv[22]; u8 rsv1[2];
u8 vf_id;
u8 rsv2[19];
}; };
struct hclge_vlan_filter_pf_cfg_cmd { struct hclge_vlan_filter_pf_cfg_cmd {
......
...@@ -1148,10 +1148,10 @@ static int hclge_log_rocee_ovf_error(struct hclge_dev *hdev) ...@@ -1148,10 +1148,10 @@ static int hclge_log_rocee_ovf_error(struct hclge_dev *hdev)
return 0; return 0;
} }
static int hclge_log_and_clear_rocee_ras_error(struct hclge_dev *hdev) static enum hnae3_reset_type
hclge_log_and_clear_rocee_ras_error(struct hclge_dev *hdev)
{ {
enum hnae3_reset_type reset_type = HNAE3_FUNC_RESET; enum hnae3_reset_type reset_type = HNAE3_NONE_RESET;
struct hnae3_ae_dev *ae_dev = hdev->ae_dev;
struct device *dev = &hdev->pdev->dev; struct device *dev = &hdev->pdev->dev;
struct hclge_desc desc[2]; struct hclge_desc desc[2];
unsigned int status; unsigned int status;
...@@ -1164,17 +1164,20 @@ static int hclge_log_and_clear_rocee_ras_error(struct hclge_dev *hdev) ...@@ -1164,17 +1164,20 @@ static int hclge_log_and_clear_rocee_ras_error(struct hclge_dev *hdev)
if (ret) { if (ret) {
dev_err(dev, "failed(%d) to query ROCEE RAS INT SRC\n", ret); dev_err(dev, "failed(%d) to query ROCEE RAS INT SRC\n", ret);
/* reset everything for now */ /* reset everything for now */
HCLGE_SET_DEFAULT_RESET_REQUEST(HNAE3_GLOBAL_RESET); return HNAE3_GLOBAL_RESET;
return ret;
} }
status = le32_to_cpu(desc[0].data[0]); status = le32_to_cpu(desc[0].data[0]);
if (status & HCLGE_ROCEE_RERR_INT_MASK) if (status & HCLGE_ROCEE_RERR_INT_MASK) {
dev_warn(dev, "ROCEE RAS AXI rresp error\n"); dev_warn(dev, "ROCEE RAS AXI rresp error\n");
reset_type = HNAE3_FUNC_RESET;
}
if (status & HCLGE_ROCEE_BERR_INT_MASK) if (status & HCLGE_ROCEE_BERR_INT_MASK) {
dev_warn(dev, "ROCEE RAS AXI bresp error\n"); dev_warn(dev, "ROCEE RAS AXI bresp error\n");
reset_type = HNAE3_FUNC_RESET;
}
if (status & HCLGE_ROCEE_ECC_INT_MASK) { if (status & HCLGE_ROCEE_ECC_INT_MASK) {
dev_warn(dev, "ROCEE RAS 2bit ECC error\n"); dev_warn(dev, "ROCEE RAS 2bit ECC error\n");
...@@ -1186,9 +1189,9 @@ static int hclge_log_and_clear_rocee_ras_error(struct hclge_dev *hdev) ...@@ -1186,9 +1189,9 @@ static int hclge_log_and_clear_rocee_ras_error(struct hclge_dev *hdev)
if (ret) { if (ret) {
dev_err(dev, "failed(%d) to process ovf error\n", ret); dev_err(dev, "failed(%d) to process ovf error\n", ret);
/* reset everything for now */ /* reset everything for now */
HCLGE_SET_DEFAULT_RESET_REQUEST(HNAE3_GLOBAL_RESET); return HNAE3_GLOBAL_RESET;
return ret;
} }
reset_type = HNAE3_FUNC_RESET;
} }
/* clear error status */ /* clear error status */
...@@ -1197,12 +1200,10 @@ static int hclge_log_and_clear_rocee_ras_error(struct hclge_dev *hdev) ...@@ -1197,12 +1200,10 @@ static int hclge_log_and_clear_rocee_ras_error(struct hclge_dev *hdev)
if (ret) { if (ret) {
dev_err(dev, "failed(%d) to clear ROCEE RAS error\n", ret); dev_err(dev, "failed(%d) to clear ROCEE RAS error\n", ret);
/* reset everything for now */ /* reset everything for now */
reset_type = HNAE3_GLOBAL_RESET; return HNAE3_GLOBAL_RESET;
} }
HCLGE_SET_DEFAULT_RESET_REQUEST(reset_type); return reset_type;
return ret;
} }
static int hclge_config_rocee_ras_interrupt(struct hclge_dev *hdev, bool en) static int hclge_config_rocee_ras_interrupt(struct hclge_dev *hdev, bool en)
...@@ -1232,15 +1233,18 @@ static int hclge_config_rocee_ras_interrupt(struct hclge_dev *hdev, bool en) ...@@ -1232,15 +1233,18 @@ static int hclge_config_rocee_ras_interrupt(struct hclge_dev *hdev, bool en)
return ret; return ret;
} }
static int hclge_handle_rocee_ras_error(struct hnae3_ae_dev *ae_dev) static void hclge_handle_rocee_ras_error(struct hnae3_ae_dev *ae_dev)
{ {
enum hnae3_reset_type reset_type = HNAE3_NONE_RESET;
struct hclge_dev *hdev = ae_dev->priv; struct hclge_dev *hdev = ae_dev->priv;
if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state) || if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state) ||
hdev->pdev->revision < 0x21) hdev->pdev->revision < 0x21)
return HNAE3_NONE_RESET; return;
return hclge_log_and_clear_rocee_ras_error(hdev); reset_type = hclge_log_and_clear_rocee_ras_error(hdev);
if (reset_type != HNAE3_NONE_RESET)
HCLGE_SET_DEFAULT_RESET_REQUEST(reset_type);
} }
static const struct hclge_hw_blk hw_blk[] = { static const struct hclge_hw_blk hw_blk[] = {
......
...@@ -1033,7 +1033,8 @@ static int hclge_configure(struct hclge_dev *hdev) ...@@ -1033,7 +1033,8 @@ static int hclge_configure(struct hclge_dev *hdev)
ether_addr_copy(hdev->hw.mac.mac_addr, cfg.mac_addr); ether_addr_copy(hdev->hw.mac.mac_addr, cfg.mac_addr);
hdev->hw.mac.media_type = cfg.media_type; hdev->hw.mac.media_type = cfg.media_type;
hdev->hw.mac.phy_addr = cfg.phy_addr; hdev->hw.mac.phy_addr = cfg.phy_addr;
hdev->num_desc = cfg.tqp_desc_num; hdev->num_tx_desc = cfg.tqp_desc_num;
hdev->num_rx_desc = cfg.tqp_desc_num;
hdev->tm_info.num_pg = 1; hdev->tm_info.num_pg = 1;
hdev->tc_max = cfg.tc_num; hdev->tc_max = cfg.tc_num;
hdev->tm_info.hw_pfc_map = 0; hdev->tm_info.hw_pfc_map = 0;
...@@ -1140,7 +1141,8 @@ static int hclge_alloc_tqps(struct hclge_dev *hdev) ...@@ -1140,7 +1141,8 @@ static int hclge_alloc_tqps(struct hclge_dev *hdev)
tqp->q.ae_algo = &ae_algo; tqp->q.ae_algo = &ae_algo;
tqp->q.buf_size = hdev->rx_buf_len; tqp->q.buf_size = hdev->rx_buf_len;
tqp->q.desc_num = hdev->num_desc; tqp->q.tx_desc_num = hdev->num_tx_desc;
tqp->q.rx_desc_num = hdev->num_rx_desc;
tqp->q.io_base = hdev->hw.io_base + HCLGE_TQP_REG_OFFSET + tqp->q.io_base = hdev->hw.io_base + HCLGE_TQP_REG_OFFSET +
i * HCLGE_TQP_REG_SIZE; i * HCLGE_TQP_REG_SIZE;
...@@ -1184,7 +1186,8 @@ static int hclge_assign_tqp(struct hclge_vport *vport, u16 num_tqps) ...@@ -1184,7 +1186,8 @@ static int hclge_assign_tqp(struct hclge_vport *vport, u16 num_tqps)
if (!hdev->htqp[i].alloced) { if (!hdev->htqp[i].alloced) {
hdev->htqp[i].q.handle = &vport->nic; hdev->htqp[i].q.handle = &vport->nic;
hdev->htqp[i].q.tqp_index = alloced; hdev->htqp[i].q.tqp_index = alloced;
hdev->htqp[i].q.desc_num = kinfo->num_desc; hdev->htqp[i].q.tx_desc_num = kinfo->num_tx_desc;
hdev->htqp[i].q.rx_desc_num = kinfo->num_rx_desc;
kinfo->tqp[alloced] = &hdev->htqp[i].q; kinfo->tqp[alloced] = &hdev->htqp[i].q;
hdev->htqp[i].alloced = true; hdev->htqp[i].alloced = true;
alloced++; alloced++;
...@@ -1197,15 +1200,18 @@ static int hclge_assign_tqp(struct hclge_vport *vport, u16 num_tqps) ...@@ -1197,15 +1200,18 @@ static int hclge_assign_tqp(struct hclge_vport *vport, u16 num_tqps)
return 0; return 0;
} }
static int hclge_knic_setup(struct hclge_vport *vport, static int hclge_knic_setup(struct hclge_vport *vport, u16 num_tqps,
u16 num_tqps, u16 num_desc) u16 num_tx_desc, u16 num_rx_desc)
{ {
struct hnae3_handle *nic = &vport->nic; struct hnae3_handle *nic = &vport->nic;
struct hnae3_knic_private_info *kinfo = &nic->kinfo; struct hnae3_knic_private_info *kinfo = &nic->kinfo;
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
int ret; int ret;
kinfo->num_desc = num_desc; kinfo->num_tx_desc = num_tx_desc;
kinfo->num_rx_desc = num_rx_desc;
kinfo->rx_buf_len = hdev->rx_buf_len; kinfo->rx_buf_len = hdev->rx_buf_len;
kinfo->tqp = devm_kcalloc(&hdev->pdev->dev, num_tqps, kinfo->tqp = devm_kcalloc(&hdev->pdev->dev, num_tqps,
...@@ -1279,7 +1285,9 @@ static int hclge_vport_setup(struct hclge_vport *vport, u16 num_tqps) ...@@ -1279,7 +1285,9 @@ static int hclge_vport_setup(struct hclge_vport *vport, u16 num_tqps)
nic->numa_node_mask = hdev->numa_node_mask; nic->numa_node_mask = hdev->numa_node_mask;
if (hdev->ae_dev->dev_type == HNAE3_DEV_KNIC) { if (hdev->ae_dev->dev_type == HNAE3_DEV_KNIC) {
ret = hclge_knic_setup(vport, num_tqps, hdev->num_desc); ret = hclge_knic_setup(vport, num_tqps,
hdev->num_tx_desc, hdev->num_rx_desc);
if (ret) { if (ret) {
dev_err(&hdev->pdev->dev, "knic setup failed %d\n", dev_err(&hdev->pdev->dev, "knic setup failed %d\n",
ret); ret);
...@@ -6329,7 +6337,7 @@ static int hclge_do_ioctl(struct hnae3_handle *handle, struct ifreq *ifr, ...@@ -6329,7 +6337,7 @@ static int hclge_do_ioctl(struct hnae3_handle *handle, struct ifreq *ifr,
} }
static int hclge_set_vlan_filter_ctrl(struct hclge_dev *hdev, u8 vlan_type, static int hclge_set_vlan_filter_ctrl(struct hclge_dev *hdev, u8 vlan_type,
u8 fe_type, bool filter_en) u8 fe_type, bool filter_en, u8 vf_id)
{ {
struct hclge_vlan_filter_ctrl_cmd *req; struct hclge_vlan_filter_ctrl_cmd *req;
struct hclge_desc desc; struct hclge_desc desc;
...@@ -6340,6 +6348,7 @@ static int hclge_set_vlan_filter_ctrl(struct hclge_dev *hdev, u8 vlan_type, ...@@ -6340,6 +6348,7 @@ static int hclge_set_vlan_filter_ctrl(struct hclge_dev *hdev, u8 vlan_type,
req = (struct hclge_vlan_filter_ctrl_cmd *)desc.data; req = (struct hclge_vlan_filter_ctrl_cmd *)desc.data;
req->vlan_type = vlan_type; req->vlan_type = vlan_type;
req->vlan_fe = filter_en ? fe_type : 0; req->vlan_fe = filter_en ? fe_type : 0;
req->vf_id = vf_id;
ret = hclge_cmd_send(&hdev->hw, &desc, 1); ret = hclge_cmd_send(&hdev->hw, &desc, 1);
if (ret) if (ret)
...@@ -6368,12 +6377,13 @@ static void hclge_enable_vlan_filter(struct hnae3_handle *handle, bool enable) ...@@ -6368,12 +6377,13 @@ static void hclge_enable_vlan_filter(struct hnae3_handle *handle, bool enable)
if (hdev->pdev->revision >= 0x21) { if (hdev->pdev->revision >= 0x21) {
hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF, hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF,
HCLGE_FILTER_FE_EGRESS, enable); HCLGE_FILTER_FE_EGRESS, enable, 0);
hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_PORT, hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_PORT,
HCLGE_FILTER_FE_INGRESS, enable); HCLGE_FILTER_FE_INGRESS, enable, 0);
} else { } else {
hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF, hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF,
HCLGE_FILTER_FE_EGRESS_V1_B, enable); HCLGE_FILTER_FE_EGRESS_V1_B, enable,
0);
} }
if (enable) if (enable)
handle->netdev_flags |= HNAE3_VLAN_FLTR; handle->netdev_flags |= HNAE3_VLAN_FLTR;
...@@ -6681,19 +6691,27 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev) ...@@ -6681,19 +6691,27 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev)
int i; int i;
if (hdev->pdev->revision >= 0x21) { if (hdev->pdev->revision >= 0x21) {
ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF, /* for revision 0x21, vf vlan filter is per function */
HCLGE_FILTER_FE_EGRESS, true); for (i = 0; i < hdev->num_alloc_vport; i++) {
vport = &hdev->vport[i];
ret = hclge_set_vlan_filter_ctrl(hdev,
HCLGE_FILTER_TYPE_VF,
HCLGE_FILTER_FE_EGRESS,
true,
vport->vport_id);
if (ret) if (ret)
return ret; return ret;
}
ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_PORT, ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_PORT,
HCLGE_FILTER_FE_INGRESS, true); HCLGE_FILTER_FE_INGRESS, true,
0);
if (ret) if (ret)
return ret; return ret;
} else { } else {
ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF, ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF,
HCLGE_FILTER_FE_EGRESS_V1_B, HCLGE_FILTER_FE_EGRESS_V1_B,
true); true, 0);
if (ret) if (ret)
return ret; return ret;
} }
......
...@@ -706,7 +706,8 @@ struct hclge_dev { ...@@ -706,7 +706,8 @@ struct hclge_dev {
u16 num_alloc_vport; /* Num vports this driver supports */ u16 num_alloc_vport; /* Num vports this driver supports */
u32 numa_node_mask; u32 numa_node_mask;
u16 rx_buf_len; u16 rx_buf_len;
u16 num_desc; u16 num_tx_desc; /* desc num of per tx queue */
u16 num_rx_desc; /* desc num of per rx queue */
u8 hw_tc_map; u8 hw_tc_map;
u8 tc_num_last_time; u8 tc_num_last_time;
enum hclge_fc_mode fc_mode_last_time; enum hclge_fc_mode fc_mode_last_time;
......
...@@ -357,20 +357,34 @@ static int hclge_get_vf_queue_info(struct hclge_vport *vport, ...@@ -357,20 +357,34 @@ static int hclge_get_vf_queue_info(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req, struct hclge_mbx_vf_to_pf_cmd *mbx_req,
bool gen_resp) bool gen_resp)
{ {
#define HCLGE_TQPS_RSS_INFO_LEN 8 #define HCLGE_TQPS_RSS_INFO_LEN 6
u8 resp_data[HCLGE_TQPS_RSS_INFO_LEN]; u8 resp_data[HCLGE_TQPS_RSS_INFO_LEN];
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
/* get the queue related info */ /* get the queue related info */
memcpy(&resp_data[0], &vport->alloc_tqps, sizeof(u16)); memcpy(&resp_data[0], &vport->alloc_tqps, sizeof(u16));
memcpy(&resp_data[2], &vport->nic.kinfo.rss_size, sizeof(u16)); memcpy(&resp_data[2], &vport->nic.kinfo.rss_size, sizeof(u16));
memcpy(&resp_data[4], &hdev->num_desc, sizeof(u16)); memcpy(&resp_data[4], &hdev->rx_buf_len, sizeof(u16));
memcpy(&resp_data[6], &hdev->rx_buf_len, sizeof(u16));
return hclge_gen_resp_to_vf(vport, mbx_req, 0, resp_data, return hclge_gen_resp_to_vf(vport, mbx_req, 0, resp_data,
HCLGE_TQPS_RSS_INFO_LEN); HCLGE_TQPS_RSS_INFO_LEN);
} }
static int hclge_get_vf_queue_depth(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req,
bool gen_resp)
{
#define HCLGE_TQPS_DEPTH_INFO_LEN 4
u8 resp_data[HCLGE_TQPS_DEPTH_INFO_LEN];
struct hclge_dev *hdev = vport->back;
/* get the queue depth info */
memcpy(&resp_data[0], &hdev->num_tx_desc, sizeof(u16));
memcpy(&resp_data[2], &hdev->num_rx_desc, sizeof(u16));
return hclge_gen_resp_to_vf(vport, mbx_req, 0, resp_data,
HCLGE_TQPS_DEPTH_INFO_LEN);
}
static int hclge_get_link_info(struct hclge_vport *vport, static int hclge_get_link_info(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req) struct hclge_mbx_vf_to_pf_cmd *mbx_req)
{ {
...@@ -476,6 +490,24 @@ static int hclge_get_queue_id_in_pf(struct hclge_vport *vport, ...@@ -476,6 +490,24 @@ static int hclge_get_queue_id_in_pf(struct hclge_vport *vport,
return hclge_gen_resp_to_vf(vport, mbx_req, 0, resp_data, 2); return hclge_gen_resp_to_vf(vport, mbx_req, 0, resp_data, 2);
} }
static int hclge_get_rss_key(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req)
{
#define HCLGE_RSS_MBX_RESP_LEN 8
u8 resp_data[HCLGE_RSS_MBX_RESP_LEN];
struct hclge_dev *hdev = vport->back;
u8 index;
index = mbx_req->msg[2];
memcpy(&resp_data[0],
&hdev->vport[0].rss_hash_key[index * HCLGE_RSS_MBX_RESP_LEN],
HCLGE_RSS_MBX_RESP_LEN);
return hclge_gen_resp_to_vf(vport, mbx_req, 0, resp_data,
HCLGE_RSS_MBX_RESP_LEN);
}
static bool hclge_cmd_crq_empty(struct hclge_hw *hw) static bool hclge_cmd_crq_empty(struct hclge_hw *hw)
{ {
u32 tail = hclge_read_dev(hw, HCLGE_NIC_CRQ_TAIL_REG); u32 tail = hclge_read_dev(hw, HCLGE_NIC_CRQ_TAIL_REG);
...@@ -567,6 +599,14 @@ void hclge_mbx_handler(struct hclge_dev *hdev) ...@@ -567,6 +599,14 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
"PF failed(%d) to get Q info for VF\n", "PF failed(%d) to get Q info for VF\n",
ret); ret);
break; break;
case HCLGE_MBX_GET_QDEPTH:
ret = hclge_get_vf_queue_depth(vport, req, true);
if (ret)
dev_err(&hdev->pdev->dev,
"PF failed(%d) to get Q depth for VF\n",
ret);
break;
case HCLGE_MBX_GET_TCINFO: case HCLGE_MBX_GET_TCINFO:
ret = hclge_get_vf_tcinfo(vport, req, true); ret = hclge_get_vf_tcinfo(vport, req, true);
if (ret) if (ret)
...@@ -603,6 +643,13 @@ void hclge_mbx_handler(struct hclge_dev *hdev) ...@@ -603,6 +643,13 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
"PF failed(%d) to get qid for VF\n", "PF failed(%d) to get qid for VF\n",
ret); ret);
break; break;
case HCLGE_MBX_GET_RSS_KEY:
ret = hclge_get_rss_key(vport, req);
if (ret)
dev_err(&hdev->pdev->dev,
"PF fail(%d) to get rss key for VF\n",
ret);
break;
case HCLGE_MBX_GET_LINK_MODE: case HCLGE_MBX_GET_LINK_MODE:
hclge_get_link_mode(vport, req); hclge_get_link_mode(vport, req);
break; break;
......
...@@ -247,7 +247,7 @@ static int hclgevf_get_tc_info(struct hclgevf_dev *hdev) ...@@ -247,7 +247,7 @@ static int hclgevf_get_tc_info(struct hclgevf_dev *hdev)
static int hclgevf_get_queue_info(struct hclgevf_dev *hdev) static int hclgevf_get_queue_info(struct hclgevf_dev *hdev)
{ {
#define HCLGEVF_TQPS_RSS_INFO_LEN 8 #define HCLGEVF_TQPS_RSS_INFO_LEN 6
u8 resp_msg[HCLGEVF_TQPS_RSS_INFO_LEN]; u8 resp_msg[HCLGEVF_TQPS_RSS_INFO_LEN];
int status; int status;
...@@ -263,8 +263,29 @@ static int hclgevf_get_queue_info(struct hclgevf_dev *hdev) ...@@ -263,8 +263,29 @@ static int hclgevf_get_queue_info(struct hclgevf_dev *hdev)
memcpy(&hdev->num_tqps, &resp_msg[0], sizeof(u16)); memcpy(&hdev->num_tqps, &resp_msg[0], sizeof(u16));
memcpy(&hdev->rss_size_max, &resp_msg[2], sizeof(u16)); memcpy(&hdev->rss_size_max, &resp_msg[2], sizeof(u16));
memcpy(&hdev->num_desc, &resp_msg[4], sizeof(u16)); memcpy(&hdev->rx_buf_len, &resp_msg[4], sizeof(u16));
memcpy(&hdev->rx_buf_len, &resp_msg[6], sizeof(u16));
return 0;
}
static int hclgevf_get_queue_depth(struct hclgevf_dev *hdev)
{
#define HCLGEVF_TQPS_DEPTH_INFO_LEN 4
u8 resp_msg[HCLGEVF_TQPS_DEPTH_INFO_LEN];
int ret;
ret = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_GET_QDEPTH, 0, NULL, 0,
true, resp_msg,
HCLGEVF_TQPS_DEPTH_INFO_LEN);
if (ret) {
dev_err(&hdev->pdev->dev,
"VF request to get tqp depth info from PF failed %d",
ret);
return ret;
}
memcpy(&hdev->num_tx_desc, &resp_msg[0], sizeof(u16));
memcpy(&hdev->num_rx_desc, &resp_msg[2], sizeof(u16));
return 0; return 0;
} }
...@@ -304,7 +325,8 @@ static int hclgevf_alloc_tqps(struct hclgevf_dev *hdev) ...@@ -304,7 +325,8 @@ static int hclgevf_alloc_tqps(struct hclgevf_dev *hdev)
tqp->q.ae_algo = &ae_algovf; tqp->q.ae_algo = &ae_algovf;
tqp->q.buf_size = hdev->rx_buf_len; tqp->q.buf_size = hdev->rx_buf_len;
tqp->q.desc_num = hdev->num_desc; tqp->q.tx_desc_num = hdev->num_tx_desc;
tqp->q.rx_desc_num = hdev->num_rx_desc;
tqp->q.io_base = hdev->hw.io_base + HCLGEVF_TQP_REG_OFFSET + tqp->q.io_base = hdev->hw.io_base + HCLGEVF_TQP_REG_OFFSET +
i * HCLGEVF_TQP_REG_SIZE; i * HCLGEVF_TQP_REG_SIZE;
...@@ -323,7 +345,8 @@ static int hclgevf_knic_setup(struct hclgevf_dev *hdev) ...@@ -323,7 +345,8 @@ static int hclgevf_knic_setup(struct hclgevf_dev *hdev)
kinfo = &nic->kinfo; kinfo = &nic->kinfo;
kinfo->num_tc = 0; kinfo->num_tc = 0;
kinfo->num_desc = hdev->num_desc; kinfo->num_tx_desc = hdev->num_tx_desc;
kinfo->num_rx_desc = hdev->num_rx_desc;
kinfo->rx_buf_len = hdev->rx_buf_len; kinfo->rx_buf_len = hdev->rx_buf_len;
for (i = 0; i < HCLGEVF_MAX_TC_NUM; i++) for (i = 0; i < HCLGEVF_MAX_TC_NUM; i++)
if (hdev->hw_tc_map & BIT(i)) if (hdev->hw_tc_map & BIT(i))
...@@ -597,12 +620,50 @@ static int hclgevf_set_rss_tc_mode(struct hclgevf_dev *hdev, u16 rss_size) ...@@ -597,12 +620,50 @@ static int hclgevf_set_rss_tc_mode(struct hclgevf_dev *hdev, u16 rss_size)
return status; return status;
} }
/* for revision 0x20, vf shared the same rss config with pf */
static int hclgevf_get_rss_hash_key(struct hclgevf_dev *hdev)
{
#define HCLGEVF_RSS_MBX_RESP_LEN 8
struct hclgevf_rss_cfg *rss_cfg = &hdev->rss_cfg;
u8 resp_msg[HCLGEVF_RSS_MBX_RESP_LEN];
u16 msg_num, hash_key_index;
u8 index;
int ret;
msg_num = (HCLGEVF_RSS_KEY_SIZE + HCLGEVF_RSS_MBX_RESP_LEN - 1) /
HCLGEVF_RSS_MBX_RESP_LEN;
for (index = 0; index < msg_num; index++) {
ret = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_GET_RSS_KEY, 0,
&index, sizeof(index),
true, resp_msg,
HCLGEVF_RSS_MBX_RESP_LEN);
if (ret) {
dev_err(&hdev->pdev->dev,
"VF get rss hash key from PF failed, ret=%d",
ret);
return ret;
}
hash_key_index = HCLGEVF_RSS_MBX_RESP_LEN * index;
if (index == msg_num - 1)
memcpy(&rss_cfg->rss_hash_key[hash_key_index],
&resp_msg[0],
HCLGEVF_RSS_KEY_SIZE - hash_key_index);
else
memcpy(&rss_cfg->rss_hash_key[hash_key_index],
&resp_msg[0], HCLGEVF_RSS_MBX_RESP_LEN);
}
return 0;
}
static int hclgevf_get_rss(struct hnae3_handle *handle, u32 *indir, u8 *key, static int hclgevf_get_rss(struct hnae3_handle *handle, u32 *indir, u8 *key,
u8 *hfunc) u8 *hfunc)
{ {
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
struct hclgevf_rss_cfg *rss_cfg = &hdev->rss_cfg; struct hclgevf_rss_cfg *rss_cfg = &hdev->rss_cfg;
int i; int i, ret;
if (handle->pdev->revision >= 0x21) { if (handle->pdev->revision >= 0x21) {
/* Get hash algorithm */ /* Get hash algorithm */
...@@ -624,6 +685,16 @@ static int hclgevf_get_rss(struct hnae3_handle *handle, u32 *indir, u8 *key, ...@@ -624,6 +685,16 @@ static int hclgevf_get_rss(struct hnae3_handle *handle, u32 *indir, u8 *key,
if (key) if (key)
memcpy(key, rss_cfg->rss_hash_key, memcpy(key, rss_cfg->rss_hash_key,
HCLGEVF_RSS_KEY_SIZE); HCLGEVF_RSS_KEY_SIZE);
} else {
if (hfunc)
*hfunc = ETH_RSS_HASH_TOP;
if (key) {
ret = hclgevf_get_rss_hash_key(hdev);
if (ret)
return ret;
memcpy(key, rss_cfg->rss_hash_key,
HCLGEVF_RSS_KEY_SIZE);
}
} }
if (indir) if (indir)
...@@ -1747,6 +1818,12 @@ static int hclgevf_configure(struct hclgevf_dev *hdev) ...@@ -1747,6 +1818,12 @@ static int hclgevf_configure(struct hclgevf_dev *hdev)
ret = hclgevf_get_queue_info(hdev); ret = hclgevf_get_queue_info(hdev);
if (ret) if (ret)
return ret; return ret;
/* get queue depth info from PF */
ret = hclgevf_get_queue_depth(hdev);
if (ret)
return ret;
/* get tc configuration from PF */ /* get tc configuration from PF */
return hclgevf_get_tc_info(hdev); return hclgevf_get_tc_info(hdev);
} }
......
...@@ -239,7 +239,8 @@ struct hclgevf_dev { ...@@ -239,7 +239,8 @@ struct hclgevf_dev {
u16 num_alloc_vport; /* num vports this driver supports */ u16 num_alloc_vport; /* num vports this driver supports */
u32 numa_node_mask; u32 numa_node_mask;
u16 rx_buf_len; u16 rx_buf_len;
u16 num_desc; u16 num_tx_desc; /* desc num of per tx queue */
u16 num_rx_desc; /* desc num of per rx queue */
u8 hw_tc_map; u8 hw_tc_map;
u16 num_msi; u16 num_msi;
......
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