[PATCH net-next 03/14] net: bcmgenet: move feature flags to bcmgenet_priv

Doug Berger
2025-03-06T19:27:26Z

The feature flags are moved and consolidated to the primary
private driver structure and are now initialized from the
platform device data rather than the hardware parameters to
allow finer control over which platforms use which features.

Signed-off-by: Doug Berger <opendmb@gmail.com>
---
.../net/ethernet/broadcom/genet/bcmgenet.c | 22 ++++++++++++-------
.../net/ethernet/broadcom/genet/bcmgenet.h | 14 ++++++------
2 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 769d920a0fc0..48830942afa8 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -3757,7 +3757,6 @@ static const struct bcmgenet_hw_params bcmgenet_hw_params_v2 = {
.rdma_offset = 0x3000,
.tdma_offset = 0x4000,
.words_per_bd = 2,
- .flags = GENET_HAS_EXT,
};

static const struct bcmgenet_hw_params bcmgenet_hw_params_v3 = {
@@ -3776,8 +3775,6 @@ static const struct bcmgenet_hw_params bcmgenet_hw_params_v3 = {
.rdma_offset = 0x10000,
.tdma_offset = 0x11000,
.words_per_bd = 2,
- .flags = GENET_HAS_EXT | GENET_HAS_MDIO_INTR |
- GENET_HAS_MOCA_LINK_DET,
};

static const struct bcmgenet_hw_params bcmgenet_hw_params_v4 = {
@@ -3796,8 +3793,6 @@ static const struct bcmgenet_hw_params bcmgenet_hw_params_v4 = {
.rdma_offset = 0x2000,
.tdma_offset = 0x4000,
.words_per_bd = 3,
- .flags = GENET_HAS_40BITS | GENET_HAS_EXT |
- GENET_HAS_MDIO_INTR | GENET_HAS_MOCA_LINK_DET,
};

/* Infer hardware parameters from the detected GENET version */
@@ -3906,7 +3901,7 @@ static void bcmgenet_set_hw_params(struct bcmgenet_priv *priv)
struct bcmgenet_plat_data {
enum bcmgenet_version version;
u32 dma_max_burst_length;
- bool ephy_16nm;
+ u32 flags;
};

static const struct bcmgenet_plat_data v1_plat_data = {
@@ -3917,32 +3912,43 @@ static const struct bcmgenet_plat_data v1_plat_data = {
static const struct bcmgenet_plat_data v2_plat_data = {
.version = GENET_V2,
.dma_max_burst_length = DMA_MAX_BURST_LENGTH,
+ .flags = GENET_HAS_EXT,
};

static const struct bcmgenet_plat_data v3_plat_data = {
.version = GENET_V3,
.dma_max_burst_length = DMA_MAX_BURST_LENGTH,
+ .flags = GENET_HAS_EXT | GENET_HAS_MDIO_INTR |
+ GENET_HAS_MOCA_LINK_DET,
};

static const struct bcmgenet_plat_data v4_plat_data = {
.version = GENET_V4,
.dma_max_burst_length = DMA_MAX_BURST_LENGTH,
+ .flags = GENET_HAS_40BITS | GENET_HAS_EXT |
+ GENET_HAS_MDIO_INTR | GENET_HAS_MOCA_LINK_DET,
};

static const struct bcmgenet_plat_data v5_plat_data = {
.version = GENET_V5,
.dma_max_burst_length = DMA_MAX_BURST_LENGTH,
+ .flags = GENET_HAS_40BITS | GENET_HAS_EXT |
+ GENET_HAS_MDIO_INTR | GENET_HAS_MOCA_LINK_DET,
};

static const struct bcmgenet_plat_data bcm2711_plat_data = {
.version = GENET_V5,
.dma_max_burst_length = 0x08,
+ .flags = GENET_HAS_40BITS | GENET_HAS_EXT |
+ GENET_HAS_MDIO_INTR | GENET_HAS_MOCA_LINK_DET,
};

static const struct bcmgenet_plat_data bcm7712_plat_data = {
.version = GENET_V5,
.dma_max_burst_length = DMA_MAX_BURST_LENGTH,
- .ephy_16nm = true,
+ .flags = GENET_HAS_40BITS | GENET_HAS_EXT |
+ GENET_HAS_MDIO_INTR | GENET_HAS_MOCA_LINK_DET |
+ GENET_HAS_EPHY_16NM,
};

static const struct of_device_id bcmgenet_match[] = {
@@ -4040,7 +4046,7 @@ static int bcmgenet_probe(struct platform_device *pdev)
if (pdata) {
priv->version = pdata->version;
priv->dma_max_burst_length = pdata->dma_max_burst_length;
- priv->ephy_16nm = pdata->ephy_16nm;
+ priv->flags = pdata->flags;
} else {
priv->version = pd->genet_version;
priv->dma_max_burst_length = DMA_MAX_BURST_LENGTH;
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
index 9b73ae55c0d6..a7f121503ffb 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
@@ -476,6 +476,7 @@ enum bcmgenet_version {
#define GENET_HAS_EXT (1 << 1)
#define GENET_HAS_MDIO_INTR (1 << 2)
#define GENET_HAS_MOCA_LINK_DET (1 << 3)
+#define GENET_HAS_EPHY_16NM (1 << 4)

/* BCMGENET hardware parameters, keep this structure nicely aligned
* since it is going to be used in hot paths
@@ -496,7 +497,6 @@ struct bcmgenet_hw_params {
u32 rdma_offset;
u32 tdma_offset;
u32 words_per_bd;
- u32 flags;
};

struct bcmgenet_skb_cb {
@@ -597,6 +597,7 @@ struct bcmgenet_priv {

/* other misc variables */
const struct bcmgenet_hw_params *hw_params;
+ u32 flags;
unsigned autoneg_pause:1;
unsigned tx_pause:1;
unsigned rx_pause:1;
@@ -615,7 +616,6 @@ struct bcmgenet_priv {
phy_interface_t phy_interface;
int phy_addr;
int ext_phy;
- bool ephy_16nm;

/* Interrupt variables */
struct work_struct bcmgenet_irq_work;
@@ -652,27 +652,27 @@ struct bcmgenet_priv {

static inline bool bcmgenet_has_40bits(struct bcmgenet_priv *priv)
{
- return !!(priv->hw_params->flags & GENET_HAS_40BITS);
+ return !!(priv->flags & GENET_HAS_40BITS);
}

static inline bool bcmgenet_has_ext(struct bcmgenet_priv *priv)
{
- return !!(priv->hw_params->flags & GENET_HAS_EXT);
+ return !!(priv->flags & GENET_HAS_EXT);
}

static inline bool bcmgenet_has_mdio_intr(struct bcmgenet_priv *priv)
{
- return !!(priv->hw_params->flags & GENET_HAS_MDIO_INTR);
+ return !!(priv->flags & GENET_HAS_MDIO_INTR);
}

static inline bool bcmgenet_has_moca_link_det(struct bcmgenet_priv *priv)
{
- return !!(priv->hw_params->flags & GENET_HAS_MOCA_LINK_DET);
+ return !!(priv->flags & GENET_HAS_MOCA_LINK_DET);
}

static inline bool bcmgenet_has_ephy_16nm(struct bcmgenet_priv *priv)
{
- return priv->ephy_16nm;
+ return !!(priv->flags & GENET_HAS_EPHY_16NM);
}

#define GENET_IO_MACRO(name, offset) \
--
2.34.1