Skip to content

Commit

Permalink
bnxt_en: Fix compile errors when CONFIG_BNXT_SRIOV is not set.
Browse files Browse the repository at this point in the history
struct bnxt_pf_info needs to be always defined.  Move bnxt_update_vf_mac()
to bnxt_sriov.c and add some missing #ifdef CONFIG_BNXT_SRIOV.

Reported-by: Jim Hull <jim.hull@hpe.com>
Tested-by: Jim Hull <jim.hull@hpe.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Michael Chan authored and David S. Miller committed Oct 24, 2015
1 parent bf79586 commit 379a80a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 28 deletions.
32 changes: 7 additions & 25 deletions drivers/net/ethernet/broadcom/bnxt/bnxt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3645,6 +3645,7 @@ static int bnxt_hwrm_func_qcaps(struct bnxt *bp)
pf->max_rx_em_flows = le32_to_cpu(resp->max_rx_em_flows);
pf->max_rx_wm_flows = le32_to_cpu(resp->max_rx_wm_flows);
} else {
#ifdef CONFIG_BNXT_SRIOV
struct bnxt_vf_info *vf = &bp->vf;

vf->fw_fid = le16_to_cpu(resp->fid);
Expand All @@ -3659,6 +3660,7 @@ static int bnxt_hwrm_func_qcaps(struct bnxt *bp)
vf->max_l2_ctxs = le16_to_cpu(resp->max_l2_ctxs);
vf->max_vnics = le16_to_cpu(resp->max_vnics);
vf->max_stat_ctxs = le16_to_cpu(resp->max_stat_ctx);
#endif
}

bp->tx_push_thresh = 0;
Expand Down Expand Up @@ -3880,30 +3882,6 @@ static int bnxt_alloc_rfs_vnics(struct bnxt *bp)
#endif
}

static void bnxt_update_vf_mac(struct bnxt *bp)
{
struct hwrm_func_qcaps_input req = {0};
struct hwrm_func_qcaps_output *resp = bp->hwrm_cmd_resp_addr;

bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_QCAPS, -1, -1);
req.fid = cpu_to_le16(0xffff);

mutex_lock(&bp->hwrm_cmd_lock);
if (_hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT))
goto update_vf_mac_exit;

if (!is_valid_ether_addr(resp->perm_mac_address))
goto update_vf_mac_exit;

if (ether_addr_equal(resp->perm_mac_address, bp->vf.mac_addr))
goto update_vf_mac_exit;

memcpy(bp->vf.mac_addr, resp->perm_mac_address, ETH_ALEN);
memcpy(bp->dev->dev_addr, bp->vf.mac_addr, ETH_ALEN);
update_vf_mac_exit:
mutex_unlock(&bp->hwrm_cmd_lock);
}

static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init)
{
int rc = 0;
Expand Down Expand Up @@ -5581,18 +5559,20 @@ static int bnxt_get_max_irq(struct pci_dev *pdev)

void bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx)
{
int max_rings;
int max_rings = 0;

if (BNXT_PF(bp)) {
*max_tx = bp->pf.max_pf_tx_rings;
*max_rx = bp->pf.max_pf_rx_rings;
max_rings = min_t(int, bp->pf.max_irqs, bp->pf.max_cp_rings);
max_rings = min_t(int, max_rings, bp->pf.max_stat_ctxs);
} else {
#ifdef CONFIG_BNXT_SRIOV
*max_tx = bp->vf.max_tx_rings;
*max_rx = bp->vf.max_rx_rings;
max_rings = min_t(int, bp->vf.max_irqs, bp->vf.max_cp_rings);
max_rings = min_t(int, max_rings, bp->vf.max_stat_ctxs);
#endif
}
if (bp->flags & BNXT_FLAG_AGG_RINGS)
*max_rx >>= 1;
Expand Down Expand Up @@ -5696,8 +5676,10 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
memcpy(dev->dev_addr, bp->pf.mac_addr, ETH_ALEN);
bp->pf.max_irqs = max_irqs;
} else {
#if defined(CONFIG_BNXT_SRIOV)
memcpy(dev->dev_addr, bp->vf.mac_addr, ETH_ALEN);
bp->vf.max_irqs = max_irqs;
#endif
}
bnxt_get_max_rings(bp, &max_rx_rings, &max_tx_rings);
bp->rx_nr_rings = min_t(int, dflt_rings, max_rx_rings);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/broadcom/bnxt/bnxt.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ struct bnxt_vf_info {
void *hwrm_cmd_req_addr;
dma_addr_t hwrm_cmd_req_dma_addr;
};
#endif

struct bnxt_pf_info {
#define BNXT_FIRST_PF_FID 1
Expand Down Expand Up @@ -741,7 +742,6 @@ struct bnxt_pf_info {
dma_addr_t hwrm_cmd_req_dma_addr[4];
struct bnxt_vf_info *vf;
};
#endif

struct bnxt_ntuple_filter {
struct hlist_node hash;
Expand Down Expand Up @@ -960,9 +960,9 @@ struct bnxt {
#define BNXT_RESET_TASK_SP_EVENT 32
#define BNXT_RST_RING_SP_EVENT 64

struct bnxt_pf_info pf;
#ifdef CONFIG_BNXT_SRIOV
int nr_vfs;
struct bnxt_pf_info pf;
struct bnxt_vf_info vf;
wait_queue_head_t sriov_cfg_wait;
bool sriov_cfg;
Expand Down
31 changes: 30 additions & 1 deletion drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,31 @@ void bnxt_hwrm_exec_fwd_req(struct bnxt *bp)
i = vf_id + 1;
}
}

void bnxt_update_vf_mac(struct bnxt *bp)
{
struct hwrm_func_qcaps_input req = {0};
struct hwrm_func_qcaps_output *resp = bp->hwrm_cmd_resp_addr;

bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_QCAPS, -1, -1);
req.fid = cpu_to_le16(0xffff);

mutex_lock(&bp->hwrm_cmd_lock);
if (_hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT))
goto update_vf_mac_exit;

if (!is_valid_ether_addr(resp->perm_mac_address))
goto update_vf_mac_exit;

if (ether_addr_equal(resp->perm_mac_address, bp->vf.mac_addr))
goto update_vf_mac_exit;

memcpy(bp->vf.mac_addr, resp->perm_mac_address, ETH_ALEN);
memcpy(bp->dev->dev_addr, bp->vf.mac_addr, ETH_ALEN);
update_vf_mac_exit:
mutex_unlock(&bp->hwrm_cmd_lock);
}

#else

void bnxt_sriov_disable(struct bnxt *bp)
Expand All @@ -782,6 +807,10 @@ void bnxt_sriov_disable(struct bnxt *bp)

void bnxt_hwrm_exec_fwd_req(struct bnxt *bp)
{
netdev_err(dev, "Invalid VF message received when SRIOV is not enable\n");
netdev_err(bp->dev, "Invalid VF message received when SRIOV is not enable\n");
}

void bnxt_update_vf_mac(struct bnxt *bp)
{
}
#endif
1 change: 1 addition & 0 deletions drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ int bnxt_set_vf_spoofchk(struct net_device *, int, bool);
int bnxt_sriov_configure(struct pci_dev *pdev, int num_vfs);
void bnxt_sriov_disable(struct bnxt *);
void bnxt_hwrm_exec_fwd_req(struct bnxt *);
void bnxt_update_vf_mac(struct bnxt *);
#endif

0 comments on commit 379a80a

Please sign in to comment.