aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c')
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c221
1 files changed, 210 insertions, 11 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
index 2088063151d6..6cfb88732452 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
@@ -257,17 +257,23 @@ int bnx2x_vfpf_acquire(struct bnx2x *bp, u8 tx_count, u8 rx_count)
257 257
258 /* humble our request */ 258 /* humble our request */
259 req->resc_request.num_txqs = 259 req->resc_request.num_txqs =
260 bp->acquire_resp.resc.num_txqs; 260 min(req->resc_request.num_txqs,
261 bp->acquire_resp.resc.num_txqs);
261 req->resc_request.num_rxqs = 262 req->resc_request.num_rxqs =
262 bp->acquire_resp.resc.num_rxqs; 263 min(req->resc_request.num_rxqs,
264 bp->acquire_resp.resc.num_rxqs);
263 req->resc_request.num_sbs = 265 req->resc_request.num_sbs =
264 bp->acquire_resp.resc.num_sbs; 266 min(req->resc_request.num_sbs,
267 bp->acquire_resp.resc.num_sbs);
265 req->resc_request.num_mac_filters = 268 req->resc_request.num_mac_filters =
266 bp->acquire_resp.resc.num_mac_filters; 269 min(req->resc_request.num_mac_filters,
270 bp->acquire_resp.resc.num_mac_filters);
267 req->resc_request.num_vlan_filters = 271 req->resc_request.num_vlan_filters =
268 bp->acquire_resp.resc.num_vlan_filters; 272 min(req->resc_request.num_vlan_filters,
273 bp->acquire_resp.resc.num_vlan_filters);
269 req->resc_request.num_mc_filters = 274 req->resc_request.num_mc_filters =
270 bp->acquire_resp.resc.num_mc_filters; 275 min(req->resc_request.num_mc_filters,
276 bp->acquire_resp.resc.num_mc_filters);
271 277
272 /* Clear response buffer */ 278 /* Clear response buffer */
273 memset(&bp->vf2pf_mbox->resp, 0, 279 memset(&bp->vf2pf_mbox->resp, 0,
@@ -293,7 +299,7 @@ int bnx2x_vfpf_acquire(struct bnx2x *bp, u8 tx_count, u8 rx_count)
293 bp->common.flash_size = 0; 299 bp->common.flash_size = 0;
294 bp->flags |= 300 bp->flags |=
295 NO_WOL_FLAG | NO_ISCSI_OOO_FLAG | NO_ISCSI_FLAG | NO_FCOE_FLAG; 301 NO_WOL_FLAG | NO_ISCSI_OOO_FLAG | NO_ISCSI_FLAG | NO_FCOE_FLAG;
296 bp->igu_sb_cnt = 1; 302 bp->igu_sb_cnt = bp->acquire_resp.resc.num_sbs;
297 bp->igu_base_sb = bp->acquire_resp.resc.hw_sbs[0].hw_sb_id; 303 bp->igu_base_sb = bp->acquire_resp.resc.hw_sbs[0].hw_sb_id;
298 strlcpy(bp->fw_ver, bp->acquire_resp.pfdev_info.fw_ver, 304 strlcpy(bp->fw_ver, bp->acquire_resp.pfdev_info.fw_ver,
299 sizeof(bp->fw_ver)); 305 sizeof(bp->fw_ver));
@@ -373,6 +379,8 @@ int bnx2x_vfpf_init(struct bnx2x *bp)
373 req->stats_addr = bp->fw_stats_data_mapping + 379 req->stats_addr = bp->fw_stats_data_mapping +
374 offsetof(struct bnx2x_fw_stats_data, queue_stats); 380 offsetof(struct bnx2x_fw_stats_data, queue_stats);
375 381
382 req->stats_stride = sizeof(struct per_queue_stats);
383
376 /* add list termination tlv */ 384 /* add list termination tlv */
377 bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END, 385 bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
378 sizeof(struct channel_list_end_tlv)); 386 sizeof(struct channel_list_end_tlv));
@@ -452,12 +460,60 @@ free_irq:
452 bnx2x_free_irq(bp); 460 bnx2x_free_irq(bp);
453} 461}
454 462
463static void bnx2x_leading_vfq_init(struct bnx2x *bp, struct bnx2x_virtf *vf,
464 struct bnx2x_vf_queue *q)
465{
466 u8 cl_id = vfq_cl_id(vf, q);
467 u8 func_id = FW_VF_HANDLE(vf->abs_vfid);
468
469 /* mac */
470 bnx2x_init_mac_obj(bp, &q->mac_obj,
471 cl_id, q->cid, func_id,
472 bnx2x_vf_sp(bp, vf, mac_rdata),
473 bnx2x_vf_sp_map(bp, vf, mac_rdata),
474 BNX2X_FILTER_MAC_PENDING,
475 &vf->filter_state,
476 BNX2X_OBJ_TYPE_RX_TX,
477 &bp->macs_pool);
478 /* vlan */
479 bnx2x_init_vlan_obj(bp, &q->vlan_obj,
480 cl_id, q->cid, func_id,
481 bnx2x_vf_sp(bp, vf, vlan_rdata),
482 bnx2x_vf_sp_map(bp, vf, vlan_rdata),
483 BNX2X_FILTER_VLAN_PENDING,
484 &vf->filter_state,
485 BNX2X_OBJ_TYPE_RX_TX,
486 &bp->vlans_pool);
487
488 /* mcast */
489 bnx2x_init_mcast_obj(bp, &vf->mcast_obj, cl_id,
490 q->cid, func_id, func_id,
491 bnx2x_vf_sp(bp, vf, mcast_rdata),
492 bnx2x_vf_sp_map(bp, vf, mcast_rdata),
493 BNX2X_FILTER_MCAST_PENDING,
494 &vf->filter_state,
495 BNX2X_OBJ_TYPE_RX_TX);
496
497 /* rss */
498 bnx2x_init_rss_config_obj(bp, &vf->rss_conf_obj, cl_id, q->cid,
499 func_id, func_id,
500 bnx2x_vf_sp(bp, vf, rss_rdata),
501 bnx2x_vf_sp_map(bp, vf, rss_rdata),
502 BNX2X_FILTER_RSS_CONF_PENDING,
503 &vf->filter_state,
504 BNX2X_OBJ_TYPE_RX_TX);
505
506 vf->leading_rss = cl_id;
507 q->is_leading = true;
508}
509
455/* ask the pf to open a queue for the vf */ 510/* ask the pf to open a queue for the vf */
456int bnx2x_vfpf_setup_q(struct bnx2x *bp, int fp_idx) 511int bnx2x_vfpf_setup_q(struct bnx2x *bp, struct bnx2x_fastpath *fp,
512 bool is_leading)
457{ 513{
458 struct vfpf_setup_q_tlv *req = &bp->vf2pf_mbox->req.setup_q; 514 struct vfpf_setup_q_tlv *req = &bp->vf2pf_mbox->req.setup_q;
459 struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp; 515 struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
460 struct bnx2x_fastpath *fp = &bp->fp[fp_idx]; 516 u8 fp_idx = fp->index;
461 u16 tpa_agg_size = 0, flags = 0; 517 u16 tpa_agg_size = 0, flags = 0;
462 int rc; 518 int rc;
463 519
@@ -473,6 +529,9 @@ int bnx2x_vfpf_setup_q(struct bnx2x *bp, int fp_idx)
473 tpa_agg_size = TPA_AGG_SIZE; 529 tpa_agg_size = TPA_AGG_SIZE;
474 } 530 }
475 531
532 if (is_leading)
533 flags |= VFPF_QUEUE_FLG_LEADING_RSS;
534
476 /* calculate queue flags */ 535 /* calculate queue flags */
477 flags |= VFPF_QUEUE_FLG_STATS; 536 flags |= VFPF_QUEUE_FLG_STATS;
478 flags |= VFPF_QUEUE_FLG_CACHE_ALIGN; 537 flags |= VFPF_QUEUE_FLG_CACHE_ALIGN;
@@ -646,6 +705,71 @@ out:
646 return 0; 705 return 0;
647} 706}
648 707
708/* request pf to config rss table for vf queues*/
709int bnx2x_vfpf_config_rss(struct bnx2x *bp,
710 struct bnx2x_config_rss_params *params)
711{
712 struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
713 struct vfpf_rss_tlv *req = &bp->vf2pf_mbox->req.update_rss;
714 int rc = 0;
715
716 /* clear mailbox and prep first tlv */
717 bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_UPDATE_RSS,
718 sizeof(*req));
719
720 /* add list termination tlv */
721 bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
722 sizeof(struct channel_list_end_tlv));
723
724 memcpy(req->ind_table, params->ind_table, T_ETH_INDIRECTION_TABLE_SIZE);
725 memcpy(req->rss_key, params->rss_key, sizeof(params->rss_key));
726 req->ind_table_size = T_ETH_INDIRECTION_TABLE_SIZE;
727 req->rss_key_size = T_ETH_RSS_KEY;
728 req->rss_result_mask = params->rss_result_mask;
729
730 /* flags handled individually for backward/forward compatability */
731 if (params->rss_flags & (1 << BNX2X_RSS_MODE_DISABLED))
732 req->rss_flags |= VFPF_RSS_MODE_DISABLED;
733 if (params->rss_flags & (1 << BNX2X_RSS_MODE_REGULAR))
734 req->rss_flags |= VFPF_RSS_MODE_REGULAR;
735 if (params->rss_flags & (1 << BNX2X_RSS_SET_SRCH))
736 req->rss_flags |= VFPF_RSS_SET_SRCH;
737 if (params->rss_flags & (1 << BNX2X_RSS_IPV4))
738 req->rss_flags |= VFPF_RSS_IPV4;
739 if (params->rss_flags & (1 << BNX2X_RSS_IPV4_TCP))
740 req->rss_flags |= VFPF_RSS_IPV4_TCP;
741 if (params->rss_flags & (1 << BNX2X_RSS_IPV4_UDP))
742 req->rss_flags |= VFPF_RSS_IPV4_UDP;
743 if (params->rss_flags & (1 << BNX2X_RSS_IPV6))
744 req->rss_flags |= VFPF_RSS_IPV6;
745 if (params->rss_flags & (1 << BNX2X_RSS_IPV6_TCP))
746 req->rss_flags |= VFPF_RSS_IPV6_TCP;
747 if (params->rss_flags & (1 << BNX2X_RSS_IPV6_UDP))
748 req->rss_flags |= VFPF_RSS_IPV6_UDP;
749
750 DP(BNX2X_MSG_IOV, "rss flags %x\n", req->rss_flags);
751
752 /* output tlvs list */
753 bnx2x_dp_tlv_list(bp, req);
754
755 /* send message to pf */
756 rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
757 if (rc) {
758 BNX2X_ERR("failed to send message to pf. rc was %d\n", rc);
759 goto out;
760 }
761
762 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
763 BNX2X_ERR("failed to send rss message to PF over Vf PF channel %d\n",
764 resp->hdr.status);
765 rc = -EINVAL;
766 }
767out:
768 bnx2x_vfpf_finalize(bp, &req->first_tlv);
769
770 return 0;
771}
772
649int bnx2x_vfpf_set_mcast(struct net_device *dev) 773int bnx2x_vfpf_set_mcast(struct net_device *dev)
650{ 774{
651 struct bnx2x *bp = netdev_priv(dev); 775 struct bnx2x *bp = netdev_priv(dev);
@@ -948,7 +1072,7 @@ static void bnx2x_vf_mbx_acquire_resp(struct bnx2x *bp, struct bnx2x_virtf *vf,
948 1072
949 /* fill in pfdev info */ 1073 /* fill in pfdev info */
950 resp->pfdev_info.chip_num = bp->common.chip_id; 1074 resp->pfdev_info.chip_num = bp->common.chip_id;
951 resp->pfdev_info.db_size = (1 << BNX2X_DB_SHIFT); 1075 resp->pfdev_info.db_size = bp->db_size;
952 resp->pfdev_info.indices_per_sb = HC_SB_MAX_INDICES_E2; 1076 resp->pfdev_info.indices_per_sb = HC_SB_MAX_INDICES_E2;
953 resp->pfdev_info.pf_cap = (PFVF_CAP_RSS | 1077 resp->pfdev_info.pf_cap = (PFVF_CAP_RSS |
954 /* PFVF_CAP_DHC |*/ PFVF_CAP_TPA); 1078 /* PFVF_CAP_DHC |*/ PFVF_CAP_TPA);
@@ -1054,8 +1178,13 @@ static void bnx2x_vf_mbx_init_vf(struct bnx2x *bp, struct bnx2x_virtf *vf,
1054 /* record ghost addresses from vf message */ 1178 /* record ghost addresses from vf message */
1055 vf->spq_map = init->spq_addr; 1179 vf->spq_map = init->spq_addr;
1056 vf->fw_stat_map = init->stats_addr; 1180 vf->fw_stat_map = init->stats_addr;
1181 vf->stats_stride = init->stats_stride;
1057 vf->op_rc = bnx2x_vf_init(bp, vf, (dma_addr_t *)init->sb_addr); 1182 vf->op_rc = bnx2x_vf_init(bp, vf, (dma_addr_t *)init->sb_addr);
1058 1183
1184 /* set VF multiqueue statistics collection mode */
1185 if (init->flags & VFPF_INIT_FLG_STATS_COALESCE)
1186 vf->cfg_flags |= VF_CFG_STATS_COALESCE;
1187
1059 /* response */ 1188 /* response */
1060 bnx2x_vf_mbx_resp(bp, vf); 1189 bnx2x_vf_mbx_resp(bp, vf);
1061} 1190}
@@ -1080,6 +1209,8 @@ static void bnx2x_vf_mbx_set_q_flags(struct bnx2x *bp, u32 mbx_q_flags,
1080 __set_bit(BNX2X_Q_FLG_HC, sp_q_flags); 1209 __set_bit(BNX2X_Q_FLG_HC, sp_q_flags);
1081 if (mbx_q_flags & VFPF_QUEUE_FLG_DHC) 1210 if (mbx_q_flags & VFPF_QUEUE_FLG_DHC)
1082 __set_bit(BNX2X_Q_FLG_DHC, sp_q_flags); 1211 __set_bit(BNX2X_Q_FLG_DHC, sp_q_flags);
1212 if (mbx_q_flags & VFPF_QUEUE_FLG_LEADING_RSS)
1213 __set_bit(BNX2X_Q_FLG_LEADING_RSS, sp_q_flags);
1083 1214
1084 /* outer vlan removal is set according to PF's multi function mode */ 1215 /* outer vlan removal is set according to PF's multi function mode */
1085 if (IS_MF_SD(bp)) 1216 if (IS_MF_SD(bp))
@@ -1113,6 +1244,9 @@ static void bnx2x_vf_mbx_setup_q(struct bnx2x *bp, struct bnx2x_virtf *vf,
1113 struct bnx2x_queue_init_params *init_p; 1244 struct bnx2x_queue_init_params *init_p;
1114 struct bnx2x_queue_setup_params *setup_p; 1245 struct bnx2x_queue_setup_params *setup_p;
1115 1246
1247 if (bnx2x_vfq_is_leading(q))
1248 bnx2x_leading_vfq_init(bp, vf, q);
1249
1116 /* re-init the VF operation context */ 1250 /* re-init the VF operation context */
1117 memset(&vf->op_params.qctor, 0 , sizeof(vf->op_params.qctor)); 1251 memset(&vf->op_params.qctor, 0 , sizeof(vf->op_params.qctor));
1118 setup_p = &vf->op_params.qctor.prep_qsetup; 1252 setup_p = &vf->op_params.qctor.prep_qsetup;
@@ -1552,6 +1686,68 @@ static void bnx2x_vf_mbx_release_vf(struct bnx2x *bp, struct bnx2x_virtf *vf,
1552 bnx2x_vf_mbx_resp(bp, vf); 1686 bnx2x_vf_mbx_resp(bp, vf);
1553} 1687}
1554 1688
1689static void bnx2x_vf_mbx_update_rss(struct bnx2x *bp, struct bnx2x_virtf *vf,
1690 struct bnx2x_vf_mbx *mbx)
1691{
1692 struct bnx2x_vfop_cmd cmd = {
1693 .done = bnx2x_vf_mbx_resp,
1694 .block = false,
1695 };
1696 struct bnx2x_config_rss_params *vf_op_params = &vf->op_params.rss;
1697 struct vfpf_rss_tlv *rss_tlv = &mbx->msg->req.update_rss;
1698
1699 if (rss_tlv->ind_table_size != T_ETH_INDIRECTION_TABLE_SIZE ||
1700 rss_tlv->rss_key_size != T_ETH_RSS_KEY) {
1701 BNX2X_ERR("failing rss configuration of vf %d due to size mismatch\n",
1702 vf->index);
1703 vf->op_rc = -EINVAL;
1704 goto mbx_resp;
1705 }
1706
1707 /* set vfop params according to rss tlv */
1708 memcpy(vf_op_params->ind_table, rss_tlv->ind_table,
1709 T_ETH_INDIRECTION_TABLE_SIZE);
1710 memcpy(vf_op_params->rss_key, rss_tlv->rss_key,
1711 sizeof(rss_tlv->rss_key));
1712 vf_op_params->rss_obj = &vf->rss_conf_obj;
1713 vf_op_params->rss_result_mask = rss_tlv->rss_result_mask;
1714
1715 /* flags handled individually for backward/forward compatability */
1716 if (rss_tlv->rss_flags & VFPF_RSS_MODE_DISABLED)
1717 __set_bit(BNX2X_RSS_MODE_DISABLED, &vf_op_params->rss_flags);
1718 if (rss_tlv->rss_flags & VFPF_RSS_MODE_REGULAR)
1719 __set_bit(BNX2X_RSS_MODE_REGULAR, &vf_op_params->rss_flags);
1720 if (rss_tlv->rss_flags & VFPF_RSS_SET_SRCH)
1721 __set_bit(BNX2X_RSS_SET_SRCH, &vf_op_params->rss_flags);
1722 if (rss_tlv->rss_flags & VFPF_RSS_IPV4)
1723 __set_bit(BNX2X_RSS_IPV4, &vf_op_params->rss_flags);
1724 if (rss_tlv->rss_flags & VFPF_RSS_IPV4_TCP)
1725 __set_bit(BNX2X_RSS_IPV4_TCP, &vf_op_params->rss_flags);
1726 if (rss_tlv->rss_flags & VFPF_RSS_IPV4_UDP)
1727 __set_bit(BNX2X_RSS_IPV4_UDP, &vf_op_params->rss_flags);
1728 if (rss_tlv->rss_flags & VFPF_RSS_IPV6)
1729 __set_bit(BNX2X_RSS_IPV6, &vf_op_params->rss_flags);
1730 if (rss_tlv->rss_flags & VFPF_RSS_IPV6_TCP)
1731 __set_bit(BNX2X_RSS_IPV6_TCP, &vf_op_params->rss_flags);
1732 if (rss_tlv->rss_flags & VFPF_RSS_IPV6_UDP)
1733 __set_bit(BNX2X_RSS_IPV6_UDP, &vf_op_params->rss_flags);
1734
1735 if ((!(rss_tlv->rss_flags & VFPF_RSS_IPV4_TCP) &&
1736 rss_tlv->rss_flags & VFPF_RSS_IPV4_UDP) ||
1737 (!(rss_tlv->rss_flags & VFPF_RSS_IPV6_TCP) &&
1738 rss_tlv->rss_flags & VFPF_RSS_IPV6_UDP)) {
1739 BNX2X_ERR("about to hit a FW assert. aborting...\n");
1740 vf->op_rc = -EINVAL;
1741 goto mbx_resp;
1742 }
1743
1744 vf->op_rc = bnx2x_vfop_rss_cmd(bp, vf, &cmd);
1745
1746mbx_resp:
1747 if (vf->op_rc)
1748 bnx2x_vf_mbx_resp(bp, vf);
1749}
1750
1555/* dispatch request */ 1751/* dispatch request */
1556static void bnx2x_vf_mbx_request(struct bnx2x *bp, struct bnx2x_virtf *vf, 1752static void bnx2x_vf_mbx_request(struct bnx2x *bp, struct bnx2x_virtf *vf,
1557 struct bnx2x_vf_mbx *mbx) 1753 struct bnx2x_vf_mbx *mbx)
@@ -1588,6 +1784,9 @@ static void bnx2x_vf_mbx_request(struct bnx2x *bp, struct bnx2x_virtf *vf,
1588 case CHANNEL_TLV_RELEASE: 1784 case CHANNEL_TLV_RELEASE:
1589 bnx2x_vf_mbx_release_vf(bp, vf, mbx); 1785 bnx2x_vf_mbx_release_vf(bp, vf, mbx);
1590 break; 1786 break;
1787 case CHANNEL_TLV_UPDATE_RSS:
1788 bnx2x_vf_mbx_update_rss(bp, vf, mbx);
1789 break;
1591 } 1790 }
1592 1791
1593 } else { 1792 } else {
@@ -1607,7 +1806,7 @@ static void bnx2x_vf_mbx_request(struct bnx2x *bp, struct bnx2x_virtf *vf,
1607 /* test whether we can respond to the VF (do we have an address 1806 /* test whether we can respond to the VF (do we have an address
1608 * for it?) 1807 * for it?)
1609 */ 1808 */
1610 if (vf->state == VF_ACQUIRED) { 1809 if (vf->state == VF_ACQUIRED || vf->state == VF_ENABLED) {
1611 /* mbx_resp uses the op_rc of the VF */ 1810 /* mbx_resp uses the op_rc of the VF */
1612 vf->op_rc = PFVF_STATUS_NOT_SUPPORTED; 1811 vf->op_rc = PFVF_STATUS_NOT_SUPPORTED;
1613 1812