Skip to content

Commit db468f9

Browse files
shinas-marvelldavem330
authored andcommitted
octeon_ep_vf: add VF-PF mailbox communication.
Implement VF-PF mailbox to send all control commands from VF to PF and receive responses and notifications from PF to VF. Signed-off-by: Shinas Rasheed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5f8c64c commit db468f9

File tree

4 files changed

+581
-2
lines changed

4 files changed

+581
-2
lines changed

drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,19 @@ static netdev_tx_t octep_vf_start_xmit(struct sk_buff *skb,
187187
return NETDEV_TX_OK;
188188
}
189189

190+
int octep_vf_get_link_info(struct octep_vf_device *oct)
191+
{
192+
int ret, size;
193+
194+
ret = octep_vf_mbox_bulk_read(oct, OCTEP_PFVF_MBOX_CMD_GET_LINK_INFO,
195+
(u8 *)&oct->link_info, &size);
196+
if (ret) {
197+
dev_err(&oct->pdev->dev, "Get VF link info failed via VF Mbox\n");
198+
return ret;
199+
}
200+
return 0;
201+
}
202+
190203
/**
191204
* octep_vf_tx_timeout_task - work queue task to Handle Tx queue timeout.
192205
*
@@ -225,11 +238,84 @@ static void octep_vf_tx_timeout(struct net_device *netdev, unsigned int txqueue)
225238
queue_work(octep_vf_wq, &oct->tx_timeout_task);
226239
}
227240

241+
static int octep_vf_set_mac(struct net_device *netdev, void *p)
242+
{
243+
struct octep_vf_device *oct = netdev_priv(netdev);
244+
struct sockaddr *addr = (struct sockaddr *)p;
245+
int err;
246+
247+
if (!is_valid_ether_addr(addr->sa_data))
248+
return -EADDRNOTAVAIL;
249+
250+
err = octep_vf_mbox_set_mac_addr(oct, addr->sa_data);
251+
if (err)
252+
return err;
253+
254+
memcpy(oct->mac_addr, addr->sa_data, ETH_ALEN);
255+
eth_hw_addr_set(netdev, addr->sa_data);
256+
257+
return 0;
258+
}
259+
260+
static int octep_vf_change_mtu(struct net_device *netdev, int new_mtu)
261+
{
262+
struct octep_vf_device *oct = netdev_priv(netdev);
263+
struct octep_vf_iface_link_info *link_info;
264+
int err;
265+
266+
link_info = &oct->link_info;
267+
if (link_info->mtu == new_mtu)
268+
return 0;
269+
270+
err = octep_vf_mbox_set_mtu(oct, new_mtu);
271+
if (!err) {
272+
oct->link_info.mtu = new_mtu;
273+
netdev->mtu = new_mtu;
274+
}
275+
return err;
276+
}
277+
278+
static int octep_vf_set_features(struct net_device *netdev,
279+
netdev_features_t features)
280+
{
281+
struct octep_vf_device *oct = netdev_priv(netdev);
282+
u16 rx_offloads = 0, tx_offloads = 0;
283+
int err;
284+
285+
/* We only support features received from firmware */
286+
if ((features & netdev->hw_features) != features)
287+
return -EINVAL;
288+
289+
if (features & NETIF_F_TSO)
290+
tx_offloads |= OCTEP_VF_TX_OFFLOAD_TSO;
291+
292+
if (features & NETIF_F_TSO6)
293+
tx_offloads |= OCTEP_VF_TX_OFFLOAD_TSO;
294+
295+
if (features & NETIF_F_IP_CSUM)
296+
tx_offloads |= OCTEP_VF_TX_OFFLOAD_CKSUM;
297+
298+
if (features & NETIF_F_IPV6_CSUM)
299+
tx_offloads |= OCTEP_VF_TX_OFFLOAD_CKSUM;
300+
301+
if (features & NETIF_F_RXCSUM)
302+
rx_offloads |= OCTEP_VF_RX_OFFLOAD_CKSUM;
303+
304+
err = octep_vf_mbox_set_offloads(oct, tx_offloads, rx_offloads);
305+
if (!err)
306+
netdev->features = features;
307+
308+
return err;
309+
}
310+
228311
static const struct net_device_ops octep_vf_netdev_ops = {
229312
.ndo_open = octep_vf_open,
230313
.ndo_stop = octep_vf_stop,
231314
.ndo_start_xmit = octep_vf_start_xmit,
232315
.ndo_tx_timeout = octep_vf_tx_timeout,
316+
.ndo_set_mac_address = octep_vf_set_mac,
317+
.ndo_change_mtu = octep_vf_change_mtu,
318+
.ndo_set_features = octep_vf_set_features,
233319
};
234320

235321
static const char *octep_vf_devid_to_str(struct octep_vf_device *oct)
@@ -411,11 +497,28 @@ static int octep_vf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
411497
goto err_mbox_version;
412498
}
413499

500+
if (octep_vf_mbox_get_fw_info(octep_vf_dev)) {
501+
dev_err(&pdev->dev, "unable to get fw info\n");
502+
err = -EINVAL;
503+
goto err_mbox_version;
504+
}
505+
414506
netdev->hw_features = NETIF_F_SG;
507+
if (OCTEP_VF_TX_IP_CSUM(octep_vf_dev->fw_info.tx_ol_flags))
508+
netdev->hw_features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
509+
510+
if (OCTEP_VF_RX_IP_CSUM(octep_vf_dev->fw_info.rx_ol_flags))
511+
netdev->hw_features |= NETIF_F_RXCSUM;
512+
415513
netdev->min_mtu = OCTEP_VF_MIN_MTU;
416514
netdev->max_mtu = OCTEP_VF_MAX_MTU;
417515
netdev->mtu = OCTEP_VF_DEFAULT_MTU;
418516

517+
if (OCTEP_VF_TX_TSO(octep_vf_dev->fw_info.tx_ol_flags)) {
518+
netdev->hw_features |= NETIF_F_TSO;
519+
netif_set_tso_max_size(netdev, netdev->max_mtu);
520+
}
521+
419522
netdev->features |= netdev->hw_features;
420523
octep_vf_get_mac_addr(octep_vf_dev, octep_vf_dev->mac_addr);
421524
eth_hw_addr_set(netdev, octep_vf_dev->mac_addr);

drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ void octep_vf_device_setup_cn93(struct octep_vf_device *oct);
331331
void octep_vf_device_setup_cnxk(struct octep_vf_device *oct);
332332
int octep_vf_iq_process_completions(struct octep_vf_iq *iq, u16 budget);
333333
int octep_vf_oq_process_rx(struct octep_vf_oq *oq, int budget);
334+
int octep_vf_get_link_info(struct octep_vf_device *oct);
334335
int octep_vf_get_if_stats(struct octep_vf_device *oct);
335336
void octep_vf_mbox_work(struct work_struct *work);
336337
#endif /* _OCTEP_VF_MAIN_H_ */

0 commit comments

Comments
 (0)