Skip to content

Commit c1ef146

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Add basic WoL infrastructure.
Add code to driver probe function to check if the device is WoL capable and if Magic packet WoL filter is currently set. Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8eb992e commit c1ef146

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4532,6 +4532,9 @@ static int bnxt_hwrm_func_qcaps(struct bnxt *bp)
45324532
pf->max_tx_wm_flows = le32_to_cpu(resp->max_tx_wm_flows);
45334533
pf->max_rx_em_flows = le32_to_cpu(resp->max_rx_em_flows);
45344534
pf->max_rx_wm_flows = le32_to_cpu(resp->max_rx_wm_flows);
4535+
if (resp->flags &
4536+
cpu_to_le32(FUNC_QCAPS_RESP_FLAGS_WOL_MAGICPKT_SUPPORTED))
4537+
bp->flags |= BNXT_FLAG_WOL_CAP;
45354538
} else {
45364539
#ifdef CONFIG_BNXT_SRIOV
45374540
struct bnxt_vf_info *vf = &bp->vf;
@@ -5839,6 +5842,44 @@ static int bnxt_hwrm_port_led_qcaps(struct bnxt *bp)
58395842
return 0;
58405843
}
58415844

5845+
static u16 bnxt_hwrm_get_wol_fltrs(struct bnxt *bp, u16 handle)
5846+
{
5847+
struct hwrm_wol_filter_qcfg_input req = {0};
5848+
struct hwrm_wol_filter_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
5849+
u16 next_handle = 0;
5850+
int rc;
5851+
5852+
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_WOL_FILTER_QCFG, -1, -1);
5853+
req.port_id = cpu_to_le16(bp->pf.port_id);
5854+
req.handle = cpu_to_le16(handle);
5855+
mutex_lock(&bp->hwrm_cmd_lock);
5856+
rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
5857+
if (!rc) {
5858+
next_handle = le16_to_cpu(resp->next_handle);
5859+
if (next_handle != 0) {
5860+
if (resp->wol_type ==
5861+
WOL_FILTER_ALLOC_REQ_WOL_TYPE_MAGICPKT) {
5862+
bp->wol = 1;
5863+
bp->wol_filter_id = resp->wol_filter_id;
5864+
}
5865+
}
5866+
}
5867+
mutex_unlock(&bp->hwrm_cmd_lock);
5868+
return next_handle;
5869+
}
5870+
5871+
static void bnxt_get_wol_settings(struct bnxt *bp)
5872+
{
5873+
u16 handle = 0;
5874+
5875+
if (!BNXT_PF(bp) || !(bp->flags & BNXT_FLAG_WOL_CAP))
5876+
return;
5877+
5878+
do {
5879+
handle = bnxt_hwrm_get_wol_fltrs(bp, handle);
5880+
} while (handle && handle != 0xffff);
5881+
}
5882+
58425883
static bool bnxt_eee_config_ok(struct bnxt *bp)
58435884
{
58445885
struct ethtool_eee *eee = &bp->eee;
@@ -7575,6 +7616,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
75757616
if (rc)
75767617
goto init_err_pci_clean;
75777618

7619+
bnxt_get_wol_settings(bp);
7620+
75787621
rc = register_netdev(dev);
75797622
if (rc)
75807623
goto init_err_clr_int;

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,7 @@ struct bnxt {
989989
#define BNXT_FLAG_UDP_RSS_CAP 0x800
990990
#define BNXT_FLAG_EEE_CAP 0x1000
991991
#define BNXT_FLAG_NEW_RSS_CAP 0x2000
992+
#define BNXT_FLAG_WOL_CAP 0x4000
992993
#define BNXT_FLAG_ROCEV1_CAP 0x8000
993994
#define BNXT_FLAG_ROCEV2_CAP 0x10000
994995
#define BNXT_FLAG_ROCE_CAP (BNXT_FLAG_ROCEV1_CAP | \
@@ -1180,6 +1181,9 @@ struct bnxt {
11801181
u32 lpi_tmr_lo;
11811182
u32 lpi_tmr_hi;
11821183

1184+
u8 wol_filter_id;
1185+
u8 wol;
1186+
11831187
u8 num_leds;
11841188
struct bnxt_led_info leds[BNXT_MAX_LED];
11851189

0 commit comments

Comments
 (0)