#define BNX2X_ME_ANSWER_DELAY 100
#define BNX2X_ME_ANSWER_TRIES 10
-static inline int bnx2x_read_vf_id(struct bnx2x_softc *sc)
+static inline int bnx2x_read_vf_id(struct bnx2x_softc *sc, uint32_t *vf_id)
{
uint32_t val;
uint8_t i = 0;
while (i <= BNX2X_ME_ANSWER_TRIES) {
val = BNX2X_DB_READ(DOORBELL_ADDR(sc, 0));
- if (bnx2x_check_me_flags(val))
- return VF_ID(val);
+ if (bnx2x_check_me_flags(val)) {
+ PMD_DRV_LOG(DEBUG, sc,
+ "valid register value: 0x%08x", val);
+ *vf_id = VF_ID(val);
+ return 0;
+ }
DELAY_MS(BNX2X_ME_ANSWER_DELAY);
i++;
}
+ PMD_DRV_LOG(ERR, sc, "Invalid register value: 0x%08x", val);
+
return -EINVAL;
}
int bnx2x_vf_get_resources(struct bnx2x_softc *sc, uint8_t tx_count, uint8_t rx_count)
{
struct vf_acquire_tlv *acq = &sc->vf2pf_mbox->query[0].acquire;
- int vf_id;
+ uint32_t vf_id;
int rc;
bnx2x_vf_close(sc);
bnx2x_vf_prep(sc, &acq->first_tlv, BNX2X_VF_TLV_ACQUIRE, sizeof(*acq));
- vf_id = bnx2x_read_vf_id(sc);
- if (vf_id < 0) {
+ if (bnx2x_read_vf_id(sc, &vf_id)) {
rc = -EAGAIN;
goto out;
}
sc->igu_sb_cnt, sc->igu_base_sb);
strncpy(sc->fw_ver, sc_resp.fw_ver, sizeof(sc->fw_ver));
- if (is_valid_assigned_ether_addr(&sc_resp.resc.current_mac_addr))
- ether_addr_copy(&sc_resp.resc.current_mac_addr,
- (struct ether_addr *)sc->link_params.mac_addr);
+ if (rte_is_valid_assigned_ether_addr(&sc_resp.resc.current_mac_addr))
+ rte_ether_addr_copy(&sc_resp.resc.current_mac_addr,
+ (struct rte_ether_addr *)sc->link_params.mac_addr);
else
- eth_random_addr(sc->link_params.mac_addr);
+ rte_eth_random_addr(sc->link_params.mac_addr);
out:
bnx2x_vf_finalize(sc, &acq->first_tlv);
{
struct vf_release_tlv *query;
struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
- int vf_id = bnx2x_read_vf_id(sc);
+ uint32_t vf_id;
int rc;
- if (vf_id >= 0) {
- query = &sc->vf2pf_mbox->query[0].release;
- bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_RELEASE,
- sizeof(*query));
+ query = &sc->vf2pf_mbox->query[0].release;
+ bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_RELEASE,
+ sizeof(*query));
- query->vf_id = vf_id;
- bnx2x_add_tlv(sc, query, query->first_tlv.tl.length,
- BNX2X_VF_TLV_LIST_END,
- sizeof(struct channel_list_end_tlv));
+ if (bnx2x_read_vf_id(sc, &vf_id)) {
+ rc = -EAGAIN;
+ goto out;
+ }
- rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
- if (rc || reply->status != BNX2X_VF_STATUS_SUCCESS)
- PMD_DRV_LOG(ERR, sc, "Failed to release VF");
+ query->vf_id = vf_id;
- bnx2x_vf_finalize(sc, &query->first_tlv);
- }
+ bnx2x_add_tlv(sc, query, query->first_tlv.tl.length,
+ BNX2X_VF_TLV_LIST_END,
+ sizeof(struct channel_list_end_tlv));
+
+ rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+ if (rc || reply->status != BNX2X_VF_STATUS_SUCCESS)
+ PMD_DRV_LOG(ERR, sc, "Failed to release VF");
+
+out:
+ bnx2x_vf_finalize(sc, &query->first_tlv);
}
/* Let PF know the VF status blocks phys_addrs */
struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
int i, rc;
+ PMD_INIT_FUNC_TRACE(sc);
+
query = &sc->vf2pf_mbox->query[0].init;
bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_INIT,
sizeof(*query));
{
struct vf_close_tlv *query;
struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
- struct vf_q_op_tlv *query_op;
- int i, vf_id, rc;
-
- vf_id = bnx2x_read_vf_id(sc);
- if (vf_id > 0) {
- FOR_EACH_QUEUE(sc, i) {
- query_op = &sc->vf2pf_mbox->query[0].q_op;
- bnx2x_vf_prep(sc, &query_op->first_tlv,
- BNX2X_VF_TLV_TEARDOWN_Q,
- sizeof(*query_op));
-
- query_op->vf_qid = i;
+ uint32_t vf_id;
+ int i, rc;
- bnx2x_add_tlv(sc, query_op,
- query_op->first_tlv.tl.length,
- BNX2X_VF_TLV_LIST_END,
- sizeof(struct channel_list_end_tlv));
+ PMD_INIT_FUNC_TRACE(sc);
- rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
- if (rc || reply->status != BNX2X_VF_STATUS_SUCCESS)
- PMD_DRV_LOG(ERR, sc,
- "Bad reply for vf_q %d teardown", i);
+ FOR_EACH_QUEUE(sc, i)
+ bnx2x_vf_teardown_queue(sc, i);
- bnx2x_vf_finalize(sc, &query_op->first_tlv);
- }
+ bnx2x_vf_set_mac(sc, false);
- bnx2x_vf_set_mac(sc, false);
+ query = &sc->vf2pf_mbox->query[0].close;
+ bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_CLOSE,
+ sizeof(*query));
- query = &sc->vf2pf_mbox->query[0].close;
- bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_CLOSE,
- sizeof(*query));
+ if (bnx2x_read_vf_id(sc, &vf_id)) {
+ rc = -EAGAIN;
+ goto out;
+ }
- query->vf_id = vf_id;
+ query->vf_id = vf_id;
- bnx2x_add_tlv(sc, query, query->first_tlv.tl.length,
- BNX2X_VF_TLV_LIST_END,
- sizeof(struct channel_list_end_tlv));
+ bnx2x_add_tlv(sc, query, query->first_tlv.tl.length,
+ BNX2X_VF_TLV_LIST_END,
+ sizeof(struct channel_list_end_tlv));
- rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
- if (rc || reply->status != BNX2X_VF_STATUS_SUCCESS)
- PMD_DRV_LOG(ERR, sc,
- "Bad reply from PF for close message");
+ rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+ if (rc || reply->status != BNX2X_VF_STATUS_SUCCESS)
+ PMD_DRV_LOG(ERR, sc,
+ "Bad reply from PF for close message");
- bnx2x_vf_finalize(sc, &query->first_tlv);
- }
+out:
+ bnx2x_vf_finalize(sc, &query->first_tlv);
}
static inline uint16_t
return rc;
}
+int
+bnx2x_vf_teardown_queue(struct bnx2x_softc *sc, int qid)
+{
+ struct vf_q_op_tlv *query_op;
+ struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
+ int rc;
+
+ query_op = &sc->vf2pf_mbox->query[0].q_op;
+ bnx2x_vf_prep(sc, &query_op->first_tlv,
+ BNX2X_VF_TLV_TEARDOWN_Q,
+ sizeof(*query_op));
+
+ query_op->vf_qid = qid;
+
+ bnx2x_add_tlv(sc, query_op,
+ query_op->first_tlv.tl.length,
+ BNX2X_VF_TLV_LIST_END,
+ sizeof(struct channel_list_end_tlv));
+
+ rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+ if (rc || reply->status != BNX2X_VF_STATUS_SUCCESS)
+ PMD_DRV_LOG(ERR, sc,
+ "Bad reply for vf_q %d teardown", qid);
+
+ bnx2x_vf_finalize(sc, &query_op->first_tlv);
+
+ return rc;
+}
+
int
bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set)
{
return rc;
}
+
+int
+bnx2x_vfpf_set_mcast(struct bnx2x_softc *sc,
+ struct rte_ether_addr *mc_addrs,
+ uint32_t mc_addrs_num)
+{
+ struct vf_set_q_filters_tlv *query;
+ struct vf_common_reply_tlv *reply =
+ &sc->vf2pf_mbox->resp.common_reply;
+ int rc = 0;
+ uint32_t i = 0;
+ query = &sc->vf2pf_mbox->query[0].set_q_filters;
+ bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS,
+ sizeof(*query));
+ /* We support PFVF_MAX_MULTICAST_PER_VF mcast addresses tops */
+ if (mc_addrs_num > VF_MAX_MULTICAST_PER_VF) {
+ PMD_DRV_LOG(ERR, sc,
+ "VF supports not more than %d multicast MAC addresses",
+ VF_MAX_MULTICAST_PER_VF);
+
+ rc = -EINVAL;
+ goto out;
+ }
+
+ for (i = 0; i < mc_addrs_num; i++) {
+ PMD_DRV_LOG(DEBUG, sc, "Adding mcast MAC:%x:%x:%x:%x:%x:%x",
+ mc_addrs[i].addr_bytes[0],
+ mc_addrs[i].addr_bytes[1],
+ mc_addrs[i].addr_bytes[2],
+ mc_addrs[i].addr_bytes[3],
+ mc_addrs[i].addr_bytes[4],
+ mc_addrs[i].addr_bytes[5]);
+ memcpy(query->multicast[i], mc_addrs[i].addr_bytes, ETH_ALEN);
+ }
+
+ query->vf_qid = 0;
+ query->flags = BNX2X_VF_MULTICAST_CHANGED;
+ query->multicast_cnt = i;
+
+ /* add list termination tlv */
+ bnx2x_add_tlv(sc, query, query->first_tlv.tl.length,
+ BNX2X_VF_TLV_LIST_END,
+ sizeof(struct channel_list_end_tlv));
+ rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+ if (rc)
+ goto out;
+
+ if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
+ PMD_DRV_LOG(ERR, sc, "Set Rx mode/multicast failed: %d",
+ reply->status);
+ rc = -EINVAL;
+ }
+
+out:
+ bnx2x_vf_finalize(sc, &query->first_tlv);
+
+ return rc;
+}