Skip to content

Commit 90e2c0f

Browse files
chenhuacaiNipaLocal
authored andcommitted
net: stmmac: dwmac-loongson: Move queue number init to common function
Currently, the tx and rx queue number initialization is duplicated in loongson_gmac_data() and loongson_gnet_data(), so move it to the common function loongson_default_data(). This is a preparation for later patches. Reviewed-by: Yanteng Si <[email protected]> Tested-by: Henry Chen <[email protected]> Tested-by: Biao Dong <[email protected]> Signed-off-by: Baoqi Zhang <[email protected]> Signed-off-by: Huacai Chen <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent a167e57 commit 90e2c0f

File tree

1 file changed

+9
-31
lines changed

1 file changed

+9
-31
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ struct stmmac_pci_info {
8383
static void loongson_default_data(struct pci_dev *pdev,
8484
struct plat_stmmacenet_data *plat)
8585
{
86+
struct loongson_data *ld = plat->bsp_priv;
87+
8688
/* Get bus_id, this can be overwritten later */
8789
plat->bus_id = pci_dev_id(pdev);
8890

@@ -116,17 +118,6 @@ static void loongson_default_data(struct pci_dev *pdev,
116118

117119
plat->dma_cfg->pbl = 32;
118120
plat->dma_cfg->pblx8 = true;
119-
}
120-
121-
static int loongson_gmac_data(struct pci_dev *pdev,
122-
struct plat_stmmacenet_data *plat)
123-
{
124-
struct loongson_data *ld;
125-
int i;
126-
127-
ld = plat->bsp_priv;
128-
129-
loongson_default_data(pdev, plat);
130121

131122
if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) {
132123
plat->rx_queues_to_use = CHANNEL_NUM;
@@ -135,12 +126,18 @@ static int loongson_gmac_data(struct pci_dev *pdev,
135126
/* Only channel 0 supports checksum,
136127
* so turn off checksum to enable multiple channels.
137128
*/
138-
for (i = 1; i < CHANNEL_NUM; i++)
129+
for (int i = 1; i < CHANNEL_NUM; i++)
139130
plat->tx_queues_cfg[i].coe_unsupported = 1;
140131
} else {
141132
plat->tx_queues_to_use = 1;
142133
plat->rx_queues_to_use = 1;
143134
}
135+
}
136+
137+
static int loongson_gmac_data(struct pci_dev *pdev,
138+
struct plat_stmmacenet_data *plat)
139+
{
140+
loongson_default_data(pdev, plat);
144141

145142
plat->phy_interface = PHY_INTERFACE_MODE_RGMII_ID;
146143

@@ -172,27 +169,8 @@ static void loongson_gnet_fix_speed(void *priv, int speed, unsigned int mode)
172169
static int loongson_gnet_data(struct pci_dev *pdev,
173170
struct plat_stmmacenet_data *plat)
174171
{
175-
struct loongson_data *ld;
176-
int i;
177-
178-
ld = plat->bsp_priv;
179-
180172
loongson_default_data(pdev, plat);
181173

182-
if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) {
183-
plat->rx_queues_to_use = CHANNEL_NUM;
184-
plat->tx_queues_to_use = CHANNEL_NUM;
185-
186-
/* Only channel 0 supports checksum,
187-
* so turn off checksum to enable multiple channels.
188-
*/
189-
for (i = 1; i < CHANNEL_NUM; i++)
190-
plat->tx_queues_cfg[i].coe_unsupported = 1;
191-
} else {
192-
plat->tx_queues_to_use = 1;
193-
plat->rx_queues_to_use = 1;
194-
}
195-
196174
plat->phy_interface = PHY_INTERFACE_MODE_GMII;
197175
plat->mdio_bus_data->phy_mask = ~(u32)BIT(2);
198176
plat->fix_mac_speed = loongson_gnet_fix_speed;

0 commit comments

Comments
 (0)