Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F168960165
D4480.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
12 KB
Referenced Files
None
Subscribers
None
D4480.id.diff
View Options
Index: head/sys/dev/sfxge/common/efx_impl.h
===================================================================
--- head/sys/dev/sfxge/common/efx_impl.h
+++ head/sys/dev/sfxge/common/efx_impl.h
@@ -460,10 +460,7 @@
void (*emco_request_copyout)(efx_nic_t *, efx_mcdi_req_t *);
efx_rc_t (*emco_poll_reboot)(efx_nic_t *);
void (*emco_fini)(efx_nic_t *);
- efx_rc_t (*emco_fw_update_supported)(efx_nic_t *, boolean_t *);
- efx_rc_t (*emco_macaddr_change_supported)(efx_nic_t *, boolean_t *);
- efx_rc_t (*emco_link_control_supported)(efx_nic_t *, boolean_t *);
- efx_rc_t (*emco_mac_spoofing_supported)(efx_nic_t *, boolean_t *);
+ efx_rc_t (*emco_feature_supported)(efx_nic_t *, efx_mcdi_feature_id_t, boolean_t *);
void (*emco_read_response)(efx_nic_t *, void *, size_t, size_t);
} efx_mcdi_ops_t;
Index: head/sys/dev/sfxge/common/efx_mcdi.h
===================================================================
--- head/sys/dev/sfxge/common/efx_mcdi.h
+++ head/sys/dev/sfxge/common/efx_mcdi.h
@@ -386,11 +386,18 @@
#define MCDI_CMD_DWORD_FIELD(_edp, _field) \
EFX_DWORD_FIELD(*_edp, MC_CMD_ ## _field)
-#define EFX_MCDI_HAVE_PRIVILEGE(mask, priv) \
- (((mask) & \
- (MC_CMD_PRIVILEGE_MASK_IN_GRP_ ## priv)) == \
+#define EFX_MCDI_HAVE_PRIVILEGE(mask, priv) \
+ (((mask) & (MC_CMD_PRIVILEGE_MASK_IN_GRP_ ## priv)) == \
(MC_CMD_PRIVILEGE_MASK_IN_GRP_ ## priv))
+typedef enum efx_mcdi_feature_id_e {
+ EFX_MCDI_FEATURE_FW_UPDATE = 0,
+ EFX_MCDI_FEATURE_LINK_CONTROL,
+ EFX_MCDI_FEATURE_MACADDR_CHANGE,
+ EFX_MCDI_FEATURE_MAC_SPOOFING,
+ EFX_MCDI_FEATURE_NIDS
+} efx_mcdi_feature_id_t;
+
#ifdef __cplusplus
}
#endif
Index: head/sys/dev/sfxge/common/efx_mcdi.c
===================================================================
--- head/sys/dev/sfxge/common/efx_mcdi.c
+++ head/sys/dev/sfxge/common/efx_mcdi.c
@@ -50,12 +50,7 @@
siena_mcdi_request_copyout, /* emco_request_copyout */
siena_mcdi_poll_reboot, /* emco_poll_reboot */
siena_mcdi_fini, /* emco_fini */
- siena_mcdi_fw_update_supported, /* emco_fw_update_supported */
- siena_mcdi_macaddr_change_supported,
- /* emco_macaddr_change_supported */
- siena_mcdi_link_control_supported,
- /* emco_link_control_supported */
- NULL, /* emco_mac_spoofing_supported */
+ siena_mcdi_feature_supported, /* emco_feature_supported */
siena_mcdi_read_response, /* emco_read_response */
};
@@ -70,13 +65,7 @@
hunt_mcdi_request_copyout, /* emco_request_copyout */
hunt_mcdi_poll_reboot, /* emco_poll_reboot */
hunt_mcdi_fini, /* emco_fini */
- hunt_mcdi_fw_update_supported, /* emco_fw_update_supported */
- hunt_mcdi_macaddr_change_supported,
- /* emco_macaddr_change_supported */
- hunt_mcdi_link_control_supported,
- /* emco_link_control_supported */
- hunt_mcdi_mac_spoofing_supported,
- /* emco_mac_spoofing_supported */
+ hunt_mcdi_feature_supported, /* emco_feature_supported */
hunt_mcdi_read_response, /* emco_read_response */
};
@@ -1316,7 +1305,6 @@
return (rc);
}
-
__checkReturn efx_rc_t
efx_mcdi_firmware_update_supported(
__in efx_nic_t *enp,
@@ -1325,9 +1313,9 @@
efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
efx_rc_t rc;
- if (emcop != NULL && emcop->emco_fw_update_supported != NULL) {
- if ((rc = emcop->emco_fw_update_supported(enp, supportedp))
- != 0)
+ if (emcop != NULL) {
+ if ((rc = emcop->emco_feature_supported(enp,
+ EFX_MCDI_FEATURE_FW_UPDATE, supportedp)) != 0)
goto fail1;
} else {
/* Earlier devices always supported updates */
@@ -1350,9 +1338,9 @@
efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
efx_rc_t rc;
- if (emcop != NULL && emcop->emco_macaddr_change_supported != NULL) {
- if ((rc = emcop->emco_macaddr_change_supported(enp, supportedp))
- != 0)
+ if (emcop != NULL) {
+ if ((rc = emcop->emco_feature_supported(enp,
+ EFX_MCDI_FEATURE_MACADDR_CHANGE, supportedp)) != 0)
goto fail1;
} else {
/* Earlier devices always supported MAC changes */
@@ -1375,9 +1363,9 @@
efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
efx_rc_t rc;
- if (emcop != NULL && emcop->emco_link_control_supported != NULL) {
- if ((rc = emcop->emco_link_control_supported(enp, supportedp))
- != 0)
+ if (emcop != NULL) {
+ if ((rc = emcop->emco_feature_supported(enp,
+ EFX_MCDI_FEATURE_LINK_CONTROL, supportedp)) != 0)
goto fail1;
} else {
/* Earlier devices always supported link control */
@@ -1400,9 +1388,9 @@
efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
efx_rc_t rc;
- if (emcop != NULL && emcop->emco_mac_spoofing_supported != NULL) {
- if ((rc = emcop->emco_mac_spoofing_supported(enp, supportedp))
- != 0)
+ if (emcop != NULL) {
+ if ((rc = emcop->emco_feature_supported(enp,
+ EFX_MCDI_FEATURE_MAC_SPOOFING, supportedp)) != 0)
goto fail1;
} else {
/* Earlier devices always supported MAC spoofing */
Index: head/sys/dev/sfxge/common/hunt_impl.h
===================================================================
--- head/sys/dev/sfxge/common/hunt_impl.h
+++ head/sys/dev/sfxge/common/hunt_impl.h
@@ -284,26 +284,11 @@
__in efx_nic_t *enp);
extern __checkReturn efx_rc_t
-hunt_mcdi_fw_update_supported(
+hunt_mcdi_feature_supported(
__in efx_nic_t *enp,
+ __in efx_mcdi_feature_id_t id,
__out boolean_t *supportedp);
-extern __checkReturn efx_rc_t
-hunt_mcdi_macaddr_change_supported(
- __in efx_nic_t *enp,
- __out boolean_t *supportedp);
-
-extern __checkReturn efx_rc_t
-hunt_mcdi_link_control_supported(
- __in efx_nic_t *enp,
- __out boolean_t *supportedp);
-
-extern __checkReturn efx_rc_t
-hunt_mcdi_mac_spoofing_supported(
- __in efx_nic_t *enp,
- __out boolean_t *supportedp);
-
-
#endif /* EFSYS_OPT_MCDI */
/* NVRAM */
@@ -722,7 +707,7 @@
#define HUNT_MIN_PIO_ALLOC_SIZE (HUNT_PIOBUF_SIZE / 32)
-#define HUNT_LEGACY_PF_PRIVILEGE_MASK \
+#define HUNT_LEGACY_PF_PRIVILEGE_MASK \
(MC_CMD_PRIVILEGE_MASK_IN_GRP_ADMIN | \
MC_CMD_PRIVILEGE_MASK_IN_GRP_LINK | \
MC_CMD_PRIVILEGE_MASK_IN_GRP_ONLOAD | \
@@ -735,7 +720,7 @@
MC_CMD_PRIVILEGE_MASK_IN_GRP_ALL_MULTICAST | \
MC_CMD_PRIVILEGE_MASK_IN_GRP_PROMISCUOUS)
-#define HUNT_LEGACY_VF_PRIVILEGE_MASK 0
+#define HUNT_LEGACY_VF_PRIVILEGE_MASK 0
typedef uint32_t efx_piobuf_handle_t;
Index: head/sys/dev/sfxge/common/hunt_mcdi.c
===================================================================
--- head/sys/dev/sfxge/common/hunt_mcdi.c
+++ head/sys/dev/sfxge/common/hunt_mcdi.c
@@ -399,94 +399,73 @@
}
__checkReturn efx_rc_t
-hunt_mcdi_fw_update_supported(
- __in efx_nic_t *enp,
- __out boolean_t *supportedp)
-{
- efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
-
- EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_HUNTINGTON);
-
- /*
- * Use privilege mask state at MCDI attach.
- * Admin privilege must be used prior to introduction of
- * specific flag.
- */
- *supportedp =
- EFX_MCDI_HAVE_PRIVILEGE(encp->enc_privilege_mask, ADMIN);
-
- return (0);
-}
-
- __checkReturn efx_rc_t
-hunt_mcdi_macaddr_change_supported(
+hunt_mcdi_feature_supported(
__in efx_nic_t *enp,
+ __in efx_mcdi_feature_id_t id,
__out boolean_t *supportedp)
{
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
uint32_t privilege_mask = encp->enc_privilege_mask;
+ efx_rc_t rc;
EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_HUNTINGTON);
/*
* Use privilege mask state at MCDI attach.
- * Admin privilege must be used prior to introduction of
- * mac spoofing privilege (at v4.6), which is used up to
- * introduction of change mac spoofing privilege (at v4.7)
*/
- *supportedp =
- EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, CHANGE_MAC) ||
- EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, MAC_SPOOFING) ||
- EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, ADMIN);
-
- return (0);
-}
- __checkReturn efx_rc_t
-hunt_mcdi_mac_spoofing_supported(
- __in efx_nic_t *enp,
- __out boolean_t *supportedp)
-{
- efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
- uint32_t privilege_mask = encp->enc_privilege_mask;
-
- EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_HUNTINGTON);
-
- /*
- * Use privilege mask state at MCDI attach.
- * Admin privilege must be used prior to introduction of
- * mac spoofing privilege (at v4.6), which is used up to
- * introduction of mac spoofing TX privilege (at v4.7)
- */
- *supportedp =
- EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, MAC_SPOOFING_TX) ||
- EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, MAC_SPOOFING) ||
- EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, ADMIN);
+ switch (id) {
+ case EFX_MCDI_FEATURE_FW_UPDATE:
+ /*
+ * Admin privilege must be used prior to introduction of
+ * specific flag.
+ */
+ *supportedp =
+ EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, ADMIN);
+ break;
+ case EFX_MCDI_FEATURE_LINK_CONTROL:
+ /*
+ * Admin privilege used prior to introduction of
+ * specific flag.
+ */
+ *supportedp =
+ EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, LINK) ||
+ EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, ADMIN);
+ break;
+ case EFX_MCDI_FEATURE_MACADDR_CHANGE:
+ /*
+ * Admin privilege must be used prior to introduction of
+ * mac spoofing privilege (at v4.6), which is used up to
+ * introduction of change mac spoofing privilege (at v4.7)
+ */
+ *supportedp =
+ EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, CHANGE_MAC) ||
+ EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, MAC_SPOOFING) ||
+ EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, ADMIN);
+ break;
+ case EFX_MCDI_FEATURE_MAC_SPOOFING:
+ /*
+ * Admin privilege must be used prior to introduction of
+ * mac spoofing privilege (at v4.6), which is used up to
+ * introduction of mac spoofing TX privilege (at v4.7)
+ */
+ *supportedp =
+ EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, MAC_SPOOFING_TX) ||
+ EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, MAC_SPOOFING) ||
+ EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, ADMIN);
+ break;
+ default:
+ rc = ENOTSUP;
+ goto fail1;
+ break;
+ }
return (0);
-}
+fail1:
+ EFSYS_PROBE1(fail1, efx_rc_t, rc);
- __checkReturn efx_rc_t
-hunt_mcdi_link_control_supported(
- __in efx_nic_t *enp,
- __out boolean_t *supportedp)
-{
- efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
- uint32_t privilege_mask = encp->enc_privilege_mask;
-
- EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_HUNTINGTON);
-
- /*
- * Use privilege mask state at MCDI attach.
- * Admin privilege used prior to introduction of
- * specific flag.
- */
- *supportedp =
- EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, LINK) ||
- EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, ADMIN);
-
- return (0);
+ return (rc);
}
#endif /* EFSYS_OPT_MCDI */
Index: head/sys/dev/sfxge/common/siena_impl.h
===================================================================
--- head/sys/dev/sfxge/common/siena_impl.h
+++ head/sys/dev/sfxge/common/siena_impl.h
@@ -146,18 +146,9 @@
__in efx_nic_t *enp);
extern __checkReturn efx_rc_t
-siena_mcdi_fw_update_supported(
- __in efx_nic_t *enp,
- __out boolean_t *supportedp);
-
-extern __checkReturn efx_rc_t
-siena_mcdi_macaddr_change_supported(
- __in efx_nic_t *enp,
- __out boolean_t *supportedp);
-
-extern __checkReturn efx_rc_t
-siena_mcdi_link_control_supported(
+siena_mcdi_feature_supported(
__in efx_nic_t *enp,
+ __in efx_mcdi_feature_id_t id,
__out boolean_t *supportedp);
#endif /* EFSYS_OPT_MCDI */
Index: head/sys/dev/sfxge/common/siena_mcdi.c
===================================================================
--- head/sys/dev/sfxge/common/siena_mcdi.c
+++ head/sys/dev/sfxge/common/siena_mcdi.c
@@ -329,39 +329,34 @@
}
__checkReturn efx_rc_t
-siena_mcdi_fw_update_supported(
+siena_mcdi_feature_supported(
__in efx_nic_t *enp,
+ __in efx_mcdi_feature_id_t id,
__out boolean_t *supportedp)
{
- EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_SIENA);
-
- *supportedp = B_TRUE;
-
- return (0);
-}
+ efx_rc_t rc;
- __checkReturn efx_rc_t
-siena_mcdi_macaddr_change_supported(
- __in efx_nic_t *enp,
- __out boolean_t *supportedp)
-{
EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_SIENA);
- *supportedp = B_TRUE;
+ switch (id) {
+ case EFX_MCDI_FEATURE_FW_UPDATE:
+ case EFX_MCDI_FEATURE_LINK_CONTROL:
+ case EFX_MCDI_FEATURE_MACADDR_CHANGE:
+ case EFX_MCDI_FEATURE_MAC_SPOOFING:
+ *supportedp = B_TRUE;
+ break;
+ default:
+ rc = ENOTSUP;
+ goto fail1;
+ break;
+ }
return (0);
-}
- __checkReturn efx_rc_t
-siena_mcdi_link_control_supported(
- __in efx_nic_t *enp,
- __out boolean_t *supportedp)
-{
- EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_SIENA);
-
- *supportedp = B_TRUE;
+fail1:
+ EFSYS_PROBE1(fail1, efx_rc_t, rc);
- return (0);
+ return (rc);
}
#endif /* EFSYS_OPT_SIENA && EFSYS_OPT_MCDI */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Aug 31, 11:25 PM (11 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37708713
Default Alt Text
D4480.id.diff (12 KB)
Attached To
Mode
D4480: sfxge: consolidate privilege check functions
Attached
Detach File
Event Timeline
Log In to Comment