Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a24274aa authored by Kejian Yan's avatar Kejian Yan Committed by David S. Miller
Browse files

net: hns: add dsaf misc operation method



The misc operation for different hw platform may be different, if using
current implementation, it will add a new branch on each function for
every new hw platform, so we add a method for this operation.

Signed-off-by: default avatarKejian Yan <yankejian@huawei.com>
Signed-off-by: default avatarYisen Zhuang <Yisen.Zhuang@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 652d39b0
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -637,13 +637,15 @@ static int hns_ae_config_loopback(struct hnae_handle *handle,
	int ret;
	struct hnae_vf_cb *vf_cb = hns_ae_get_vf_cb(handle);
	struct hns_mac_cb *mac_cb = hns_get_mac_cb(handle);
	struct dsaf_device *dsaf_dev = mac_cb->dsaf_dev;

	switch (loop) {
	case MAC_INTERNALLOOP_PHY:
		ret = 0;
		break;
	case MAC_INTERNALLOOP_SERDES:
		ret = hns_mac_config_sds_loopback(vf_cb->mac_cb, en);
		ret = dsaf_dev->misc_op->cfg_serdes_loopback(vf_cb->mac_cb,
							     !!en);
		break;
	case MAC_INTERNALLOOP_MAC:
		ret = hns_mac_config_mac_loopback(vf_cb->mac_cb, loop, en);
+3 −3
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ static void hns_gmac_free(void *mac_drv)

	u32 mac_id = drv->mac_id;

	hns_dsaf_ge_srst_by_port(dsaf_dev, mac_id, 0);
	dsaf_dev->misc_op->ge_srst(dsaf_dev, mac_id, 0);
}

static void hns_gmac_set_tx_auto_pause_frames(void *mac_drv, u16 newval)
@@ -317,9 +317,9 @@ static void hns_gmac_init(void *mac_drv)

	port = drv->mac_id;

	hns_dsaf_ge_srst_by_port(dsaf_dev, port, 0);
	dsaf_dev->misc_op->ge_srst(dsaf_dev, port, 0);
	mdelay(10);
	hns_dsaf_ge_srst_by_port(dsaf_dev, port, 1);
	dsaf_dev->misc_op->ge_srst(dsaf_dev, port, 1);
	mdelay(10);
	hns_gmac_disable(mac_drv, MAC_COMM_MODE_RX_AND_TX);
	hns_gmac_tx_loop_pkt_dis(mac_drv);
+7 −7
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ void hns_mac_get_link_status(struct hns_mac_cb *mac_cb, u32 *link_status)
	else
		*link_status = 0;

	ret = hns_mac_get_sfp_prsnt(mac_cb, &sfp_prsnt);
	ret = mac_cb->dsaf_dev->misc_op->get_sfp_prsnt(mac_cb, &sfp_prsnt);
	if (!ret)
		*link_status = *link_status && sfp_prsnt;

@@ -512,7 +512,7 @@ void hns_mac_stop(struct hns_mac_cb *mac_cb)

	mac_ctrl_drv->mac_en_flg = 0;
	mac_cb->link = 0;
	cpld_led_reset(mac_cb);
	mac_cb->dsaf_dev->misc_op->cpld_reset_led(mac_cb);
}

/**
@@ -804,7 +804,7 @@ int hns_mac_get_cfg(struct dsaf_device *dsaf_dev, struct hns_mac_cb *mac_cb)
	else
		mac_cb->mac_type = HNAE_PORT_DEBUG;

	mac_cb->phy_if = hns_mac_get_phy_if(mac_cb);
	mac_cb->phy_if = dsaf_dev->misc_op->get_phy_if(mac_cb);

	ret = hns_mac_get_mode(mac_cb->phy_if);
	if (ret < 0) {
@@ -819,7 +819,7 @@ int hns_mac_get_cfg(struct dsaf_device *dsaf_dev, struct hns_mac_cb *mac_cb)
	if (ret)
		return ret;

	cpld_led_reset(mac_cb);
	mac_cb->dsaf_dev->misc_op->cpld_reset_led(mac_cb);
	mac_cb->vaddr = hns_mac_get_vaddr(dsaf_dev, mac_cb, mac_mode_idx);

	return 0;
@@ -906,7 +906,7 @@ void hns_mac_uninit(struct dsaf_device *dsaf_dev)
	int max_port_num = hns_mac_get_max_port_num(dsaf_dev);

	for (i = 0; i < max_port_num; i++) {
		cpld_led_reset(dsaf_dev->mac_cb[i]);
		dsaf_dev->misc_op->cpld_reset_led(dsaf_dev->mac_cb[i]);
		dsaf_dev->mac_cb[i] = NULL;
	}
}
@@ -989,7 +989,7 @@ void hns_set_led_opt(struct hns_mac_cb *mac_cb)
		nic_data = 0;
	mac_cb->txpkt_for_led = mac_cb->hw_stats.tx_good_pkts;
	mac_cb->rxpkt_for_led = mac_cb->hw_stats.rx_good_pkts;
	hns_cpld_set_led(mac_cb, (int)mac_cb->link,
	mac_cb->dsaf_dev->misc_op->cpld_set_led(mac_cb, (int)mac_cb->link,
			 mac_cb->speed, nic_data);
}

@@ -999,5 +999,5 @@ int hns_cpld_led_set_id(struct hns_mac_cb *mac_cb,
	if (!mac_cb || !mac_cb->cpld_ctrl)
		return 0;

	return cpld_set_led_id(mac_cb, status);
	return mac_cb->dsaf_dev->misc_op->cpld_set_led_id(mac_cb, status);
}
+0 −2
Original line number Diff line number Diff line
@@ -448,8 +448,6 @@ int hns_mac_set_pauseparam(struct hns_mac_cb *mac_cb, u32 rx_en, u32 tx_en);
int hns_mac_set_mtu(struct hns_mac_cb *mac_cb, u32 new_mtu);
int hns_mac_get_port_info(struct hns_mac_cb *mac_cb,
			  u8 *auto_neg, u16 *speed, u8 *duplex);
phy_interface_t hns_mac_get_phy_if(struct hns_mac_cb *mac_cb);
int hns_mac_config_sds_loopback(struct hns_mac_cb *mac_cb, u8 en);
int hns_mac_config_mac_loopback(struct hns_mac_cb *mac_cb,
				enum hnae_loop loop, int en);
void hns_mac_update_stats(struct hns_mac_cb *mac_cb);
+8 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include "hns_dsaf_main.h"
#include "hns_dsaf_ppe.h"
#include "hns_dsaf_rcb.h"
#include "hns_dsaf_misc.h"

const char *g_dsaf_mode_match[DSAF_MODE_MAX] = {
	[DSAF_MODE_DISABLE_2PORT_64VM] = "2port-64vf",
@@ -174,6 +175,10 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
		goto unmap_base_addr;
	}

	dsaf_dev->misc_op = hns_misc_op_get(dsaf_dev);
	if (!dsaf_dev->misc_op)
		return -ENOMEM;

	if (!dma_set_mask_and_coherent(dsaf_dev->dev, DMA_BIT_MASK(64ULL)))
		dev_dbg(dsaf_dev->dev, "set mask to 64bit\n");
	else
@@ -1296,9 +1301,9 @@ static int hns_dsaf_init_hw(struct dsaf_device *dsaf_dev)
	dev_dbg(dsaf_dev->dev,
		"hns_dsaf_init_hw begin %s !\n", dsaf_dev->ae_dev.name);

	hns_dsaf_rst(dsaf_dev, 0);
	dsaf_dev->misc_op->dsaf_reset(dsaf_dev, 0);
	mdelay(10);
	hns_dsaf_rst(dsaf_dev, 1);
	dsaf_dev->misc_op->dsaf_reset(dsaf_dev, 1);

	hns_dsaf_comm_init(dsaf_dev);

@@ -1326,7 +1331,7 @@ static int hns_dsaf_init_hw(struct dsaf_device *dsaf_dev)
static void hns_dsaf_remove_hw(struct dsaf_device *dsaf_dev)
{
	/*reset*/
	hns_dsaf_rst(dsaf_dev, 0);
	dsaf_dev->misc_op->dsaf_reset(dsaf_dev, 0);
}

/**
Loading