Skip to content

Commit 5282db6

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Add ethtool set_wol method.
And add functions to set and free magic packet filter. Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8e20236 commit 5282db6

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5842,6 +5842,38 @@ static int bnxt_hwrm_port_led_qcaps(struct bnxt *bp)
58425842
return 0;
58435843
}
58445844

5845+
int bnxt_hwrm_alloc_wol_fltr(struct bnxt *bp)
5846+
{
5847+
struct hwrm_wol_filter_alloc_input req = {0};
5848+
struct hwrm_wol_filter_alloc_output *resp = bp->hwrm_cmd_resp_addr;
5849+
int rc;
5850+
5851+
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_WOL_FILTER_ALLOC, -1, -1);
5852+
req.port_id = cpu_to_le16(bp->pf.port_id);
5853+
req.wol_type = WOL_FILTER_ALLOC_REQ_WOL_TYPE_MAGICPKT;
5854+
req.enables = cpu_to_le32(WOL_FILTER_ALLOC_REQ_ENABLES_MAC_ADDRESS);
5855+
memcpy(req.mac_address, bp->dev->dev_addr, ETH_ALEN);
5856+
mutex_lock(&bp->hwrm_cmd_lock);
5857+
rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
5858+
if (!rc)
5859+
bp->wol_filter_id = resp->wol_filter_id;
5860+
mutex_unlock(&bp->hwrm_cmd_lock);
5861+
return rc;
5862+
}
5863+
5864+
int bnxt_hwrm_free_wol_fltr(struct bnxt *bp)
5865+
{
5866+
struct hwrm_wol_filter_free_input req = {0};
5867+
int rc;
5868+
5869+
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_WOL_FILTER_FREE, -1, -1);
5870+
req.port_id = cpu_to_le16(bp->pf.port_id);
5871+
req.enables = cpu_to_le32(WOL_FILTER_FREE_REQ_ENABLES_WOL_FILTER_ID);
5872+
req.wol_filter_id = bp->wol_filter_id;
5873+
rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
5874+
return rc;
5875+
}
5876+
58455877
static u16 bnxt_hwrm_get_wol_fltrs(struct bnxt *bp, u16 handle)
58465878
{
58475879
struct hwrm_wol_filter_qcfg_input req = {0};

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,8 @@ void bnxt_tx_disable(struct bnxt *bp);
12421242
void bnxt_tx_enable(struct bnxt *bp);
12431243
int bnxt_hwrm_set_pause(struct bnxt *);
12441244
int bnxt_hwrm_set_link_setting(struct bnxt *, bool, bool);
1245+
int bnxt_hwrm_alloc_wol_fltr(struct bnxt *bp);
1246+
int bnxt_hwrm_free_wol_fltr(struct bnxt *bp);
12451247
int bnxt_hwrm_fw_set_time(struct bnxt *);
12461248
int bnxt_open_nic(struct bnxt *, bool, bool);
12471249
int bnxt_close_nic(struct bnxt *, bool, bool);

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,31 @@ static void bnxt_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
847847
}
848848
}
849849

850+
static int bnxt_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
851+
{
852+
struct bnxt *bp = netdev_priv(dev);
853+
854+
if (wol->wolopts & ~WAKE_MAGIC)
855+
return -EINVAL;
856+
857+
if (wol->wolopts & WAKE_MAGIC) {
858+
if (!(bp->flags & BNXT_FLAG_WOL_CAP))
859+
return -EINVAL;
860+
if (!bp->wol) {
861+
if (bnxt_hwrm_alloc_wol_fltr(bp))
862+
return -EBUSY;
863+
bp->wol = 1;
864+
}
865+
} else {
866+
if (bp->wol) {
867+
if (bnxt_hwrm_free_wol_fltr(bp))
868+
return -EBUSY;
869+
bp->wol = 0;
870+
}
871+
}
872+
return 0;
873+
}
874+
850875
u32 _bnxt_fw_to_ethtool_adv_spds(u16 fw_speeds, u8 fw_pause)
851876
{
852877
u32 speed_mask = 0;
@@ -2150,6 +2175,7 @@ const struct ethtool_ops bnxt_ethtool_ops = {
21502175
.set_pauseparam = bnxt_set_pauseparam,
21512176
.get_drvinfo = bnxt_get_drvinfo,
21522177
.get_wol = bnxt_get_wol,
2178+
.set_wol = bnxt_set_wol,
21532179
.get_coalesce = bnxt_get_coalesce,
21542180
.set_coalesce = bnxt_set_coalesce,
21552181
.get_msglevel = bnxt_get_msglevel,

0 commit comments

Comments
 (0)