Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F171262081
D10124.id26623.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D10124.id26623.diff
View Options
Index: sys/dev/bnxt/bnxt.h
===================================================================
--- sys/dev/bnxt/bnxt.h
+++ sys/dev/bnxt/bnxt.h
@@ -100,6 +100,9 @@
#define BNXT_RSS_HASH_TYPE_IPV6 5
#define BNXT_GET_RSS_PROFILE_ID(rss_hash_type) ((rss_hash_type >> 1) & 0x1F)
+#define BNXT_NO_MORE_WOL_FILTERS 0xFFFF
+#define bnxt_wol_supported(softc) (softc->flags & BNXT_FLAG_WOL_CAP)
+
/* Completion related defines */
#define CMP_VALID(cmp, v_bit) \
((!!(((struct cmpl_base *)(cmp))->info3_v & htole32(CMPL_BASE_V))) == !!(v_bit) )
@@ -512,7 +515,8 @@
struct bnxt_bar_info hwrm_bar;
struct bnxt_bar_info doorbell_bar;
struct bnxt_link_info link_info;
-#define BNXT_FLAG_NPAR 1
+#define BNXT_FLAG_NPAR 0x1
+#define BNXT_FLAG_WOL_CAP 0x2
uint32_t flags;
uint32_t total_msix;
@@ -562,6 +566,8 @@
struct bnxt_full_tpa_start *tpa_start;
struct bnxt_ver_info *ver_info;
struct bnxt_nvram_info *nvm_info;
+ bool wol;
+ uint8_t wol_filter_id;
};
struct bnxt_filter_info {
Index: sys/dev/bnxt/bnxt_hwrm.h
===================================================================
--- sys/dev/bnxt/bnxt_hwrm.h
+++ sys/dev/bnxt/bnxt_hwrm.h
@@ -98,5 +98,8 @@
uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second,
uint16_t millisecond, uint16_t zone);
int bnxt_hwrm_port_phy_qcfg(struct bnxt_softc *softc);
+uint16_t bnxt_hwrm_get_wol_fltrs(struct bnxt_softc *softc, uint16_t handle);
+int bnxt_hwrm_alloc_wol_fltr(struct bnxt_softc *softc);
+int bnxt_hwrm_free_wol_fltr(struct bnxt_softc *softc);
#endif
Index: sys/dev/bnxt/bnxt_hwrm.c
===================================================================
--- sys/dev/bnxt/bnxt_hwrm.c
+++ sys/dev/bnxt/bnxt_hwrm.c
@@ -398,6 +398,10 @@
if (rc)
goto fail;
+ if (resp->flags &
+ htole32(HWRM_FUNC_QCAPS_OUTPUT_FLAGS_WOL_MAGICPKT_SUPPORTED))
+ softc->flags |= BNXT_FLAG_WOL_CAP;
+
func->fw_fid = le16toh(resp->fid);
memcpy(func->mac_addr, resp->mac_address, ETHER_ADDR_LEN);
func->max_rsscos_ctxs = le16toh(resp->max_rsscos_ctx);
@@ -1483,3 +1487,64 @@
BNXT_HWRM_UNLOCK(softc);
return rc;
}
+
+uint16_t
+bnxt_hwrm_get_wol_fltrs(struct bnxt_softc *softc, uint16_t handle)
+{
+ struct hwrm_wol_filter_qcfg_input req = {0};
+ struct hwrm_wol_filter_qcfg_output *resp =
+ (void *)softc->hwrm_cmd_resp.idi_vaddr;
+ uint16_t next_handle = 0;
+ int rc;
+
+ bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_WOL_FILTER_QCFG);
+ req.port_id = htole16(softc->pf.port_id);
+ req.handle = htole16(handle);
+ rc = hwrm_send_message(softc, &req, sizeof(req));
+ if (!rc) {
+ next_handle = le16toh(resp->next_handle);
+ if (next_handle != 0) {
+ if (resp->wol_type ==
+ HWRM_WOL_FILTER_ALLOC_INPUT_WOL_TYPE_MAGICPKT) {
+ softc->wol = 1;
+ softc->wol_filter_id = resp->wol_filter_id;
+ }
+ }
+ }
+ return next_handle;
+
+}
+
+int
+bnxt_hwrm_alloc_wol_fltr(struct bnxt_softc *softc)
+{
+ struct hwrm_wol_filter_alloc_input req = {0};
+ struct hwrm_wol_filter_alloc_output *resp =
+ (void *)softc->hwrm_cmd_resp.idi_vaddr;
+ int rc;
+
+ bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_WOL_FILTER_ALLOC);
+ req.port_id = htole16(softc->pf.port_id);
+ req.wol_type = HWRM_WOL_FILTER_ALLOC_INPUT_WOL_TYPE_MAGICPKT;
+ req.enables =
+ htole32(HWRM_WOL_FILTER_ALLOC_INPUT_ENABLES_MAC_ADDRESS);
+ memcpy(req.mac_address, softc->func.mac_addr, ETHER_ADDR_LEN);
+ rc = hwrm_send_message(softc, &req, sizeof(req));
+ if (!rc)
+ softc->wol_filter_id = resp->wol_filter_id;
+
+ return rc;
+}
+
+int
+bnxt_hwrm_free_wol_fltr(struct bnxt_softc *softc)
+{
+ struct hwrm_wol_filter_free_input req = {0};
+
+ bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_WOL_FILTER_FREE);
+ req.port_id = htole16(softc->pf.port_id);
+ req.enables =
+ htole32(HWRM_WOL_FILTER_FREE_INPUT_ENABLES_WOL_FILTER_ID);
+ req.wol_filter_id = softc->wol_filter_id;
+ return hwrm_send_message(softc, &req, sizeof(req));
+}
Index: sys/dev/bnxt/bnxt_sysctl.c
===================================================================
--- sys/dev/bnxt/bnxt_sysctl.c
+++ sys/dev/bnxt/bnxt_sysctl.c
@@ -312,6 +312,43 @@
return rc;
}
+static int
+bnxt_hwrm_wol_enable(SYSCTL_HANDLER_ARGS)
+{
+ struct bnxt_softc *softc = arg1;
+ uint32_t status;
+ int val = 0;
+
+ if (softc == NULL)
+ return -EBUSY;
+
+ val = softc->wol;
+ status = sysctl_handle_int(oidp, &val, 0, req);
+ if (status || !req->newptr)
+ return status;
+
+ if ((val < 0) || (val > 1))
+ return -EINVAL;
+
+ if (val) {
+ if (!bnxt_wol_supported(softc))
+ return -EINVAL;
+ if (!softc->wol) {
+ if (bnxt_hwrm_alloc_wol_fltr(softc))
+ return -EBUSY;
+ softc->wol = 1;
+ }
+ } else {
+ if (softc->wol) {
+ if (bnxt_hwrm_free_wol_fltr(softc))
+ return -EBUSY;
+ softc->wol = 0;
+ }
+ }
+
+ return 0;
+}
+
int
bnxt_create_ver_sysctls(struct bnxt_softc *softc)
{
@@ -571,6 +608,9 @@
"strip VLAN tag in the RX path");
SYSCTL_ADD_STRING(ctx, children, OID_AUTO, "if_name", CTLFLAG_RD,
iflib_get_ifp(softc->ctx)->if_xname, 0, "interface name");
+ SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "wol",
+ CTLTYPE_INT|CTLFLAG_RWTUN, softc, 0, bnxt_hwrm_wol_enable, "I",
+ "Configure Wake-on-LAN");
return 0;
}
Index: sys/dev/bnxt/if_bnxt.c
===================================================================
--- sys/dev/bnxt/if_bnxt.c
+++ sys/dev/bnxt/if_bnxt.c
@@ -205,6 +205,7 @@
struct cmpl_base *cmpl);
static uint8_t get_phy_type(struct bnxt_softc *softc);
static uint64_t bnxt_get_baudrate(struct bnxt_link_info *link);
+static void bnxt_get_wol_settings(struct bnxt_softc *softc);
/*
* Device Interface Declaration
@@ -700,6 +701,8 @@
goto failed;
}
+ bnxt_get_wol_settings(softc);
+
/* Now perform a function reset */
rc = bnxt_hwrm_func_reset(softc);
bnxt_clear_ids(softc);
@@ -2412,3 +2415,17 @@
}
return IF_Gbps(100);
}
+
+static void
+bnxt_get_wol_settings(struct bnxt_softc *softc)
+{
+ uint16_t wol_handle = 0;
+
+ if (!bnxt_wol_supported(softc))
+ return;
+
+ do {
+ wol_handle = bnxt_hwrm_get_wol_fltrs(softc, wol_handle);
+ } while (wol_handle && wol_handle != BNXT_NO_MORE_WOL_FILTERS);
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Sep 10, 10:50 PM (1 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38671620
Default Alt Text
D10124.id26623.diff (5 KB)
Attached To
Mode
D10124: bnxt: Add support for magic packet based Wake-on-LAN.
Attached
Detach File
Event Timeline
Log In to Comment