Skip to content

Commit

Permalink
net: fman: Store en/disable in mac_device instead of mac_priv_s
Browse files Browse the repository at this point in the history
All macs use the same start/stop functions. The actual mac-specific code
lives in enable/disable. Move these functions to an appropriate struct,
and inline the phy enable/disable calls to the caller of start/stop.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Acked-by: Camelia Groza <camelia.groza@nxp.com>
Tested-by: Camelia Groza <camelia.groza@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Sean Anderson authored and Jakub Kicinski committed Aug 19, 2022
1 parent b7d8525 commit e61406a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 44 deletions.
11 changes: 7 additions & 4 deletions drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,11 @@ static int dpaa_stop(struct net_device *net_dev)
*/
msleep(200);

err = mac_dev->stop(mac_dev);
if (mac_dev->phy_dev)
phy_stop(mac_dev->phy_dev);
err = mac_dev->disable(mac_dev->fman_mac);
if (err < 0)
netif_err(priv, ifdown, net_dev, "mac_dev->stop() = %d\n",
netif_err(priv, ifdown, net_dev, "mac_dev->disable() = %d\n",
err);

for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) {
Expand Down Expand Up @@ -2942,11 +2944,12 @@ static int dpaa_open(struct net_device *net_dev)
goto mac_start_failed;
}

err = priv->mac_dev->start(mac_dev);
err = priv->mac_dev->enable(mac_dev->fman_mac);
if (err < 0) {
netif_err(priv, ifup, net_dev, "mac_dev->start() = %d\n", err);
netif_err(priv, ifup, net_dev, "mac_dev->enable() = %d\n", err);
goto mac_start_failed;
}
phy_start(priv->mac_dev->phy_dev);

netif_tx_start_all_queues(net_dev);

Expand Down
44 changes: 6 additions & 38 deletions drivers/net/ethernet/freescale/fman/mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ struct mac_priv_s {
struct fixed_phy_status *fixed_link;
u16 speed;
u16 max_speed;

int (*enable)(struct fman_mac *mac_dev);
int (*disable)(struct fman_mac *mac_dev);
};

struct mac_address {
Expand Down Expand Up @@ -241,29 +238,6 @@ static int memac_initialization(struct mac_device *mac_dev)
return err;
}

static int start(struct mac_device *mac_dev)
{
int err;
struct phy_device *phy_dev = mac_dev->phy_dev;
struct mac_priv_s *priv = mac_dev->priv;

err = priv->enable(mac_dev->fman_mac);
if (!err && phy_dev)
phy_start(phy_dev);

return err;
}

static int stop(struct mac_device *mac_dev)
{
struct mac_priv_s *priv = mac_dev->priv;

if (mac_dev->phy_dev)
phy_stop(mac_dev->phy_dev);

return priv->disable(mac_dev->fman_mac);
}

static int set_multi(struct net_device *net_dev, struct mac_device *mac_dev)
{
struct mac_priv_s *priv;
Expand Down Expand Up @@ -454,11 +428,9 @@ static void setup_dtsec(struct mac_device *mac_dev)
mac_dev->set_allmulti = dtsec_set_allmulti;
mac_dev->set_tstamp = dtsec_set_tstamp;
mac_dev->set_multi = set_multi;
mac_dev->start = start;
mac_dev->stop = stop;
mac_dev->adjust_link = adjust_link_dtsec;
mac_dev->priv->enable = dtsec_enable;
mac_dev->priv->disable = dtsec_disable;
mac_dev->enable = dtsec_enable;
mac_dev->disable = dtsec_disable;
}

static void setup_tgec(struct mac_device *mac_dev)
Expand All @@ -474,11 +446,9 @@ static void setup_tgec(struct mac_device *mac_dev)
mac_dev->set_allmulti = tgec_set_allmulti;
mac_dev->set_tstamp = tgec_set_tstamp;
mac_dev->set_multi = set_multi;
mac_dev->start = start;
mac_dev->stop = stop;
mac_dev->adjust_link = adjust_link_void;
mac_dev->priv->enable = tgec_enable;
mac_dev->priv->disable = tgec_disable;
mac_dev->enable = tgec_enable;
mac_dev->disable = tgec_disable;
}

static void setup_memac(struct mac_device *mac_dev)
Expand All @@ -494,11 +464,9 @@ static void setup_memac(struct mac_device *mac_dev)
mac_dev->set_allmulti = memac_set_allmulti;
mac_dev->set_tstamp = memac_set_tstamp;
mac_dev->set_multi = set_multi;
mac_dev->start = start;
mac_dev->stop = stop;
mac_dev->adjust_link = adjust_link_memac;
mac_dev->priv->enable = memac_enable;
mac_dev->priv->disable = memac_disable;
mac_dev->enable = memac_enable;
mac_dev->disable = memac_disable;
}

#define DTSEC_SUPPORTED \
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/freescale/fman/mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ struct mac_device {
bool allmulti;

int (*init)(struct mac_device *mac_dev);
int (*start)(struct mac_device *mac_dev);
int (*stop)(struct mac_device *mac_dev);
int (*enable)(struct fman_mac *mac_dev);
int (*disable)(struct fman_mac *mac_dev);
void (*adjust_link)(struct mac_device *mac_dev);
int (*set_promisc)(struct fman_mac *mac_dev, bool enable);
int (*change_addr)(struct fman_mac *mac_dev, const enet_addr_t *enet_addr);
Expand Down

0 comments on commit e61406a

Please sign in to comment.