
Ipoib netdev will share receive contexts with existing VNIC netdev. To achieve that, a dummy netdev is allocated with hfi1_devdata to own the receive contexts, and ipoib and VNIC netdevs will be put on top of it. Each receive context is associated with a single NAPI object. This patch adds the functions to receive incoming packets for accelerated ipoib. Link: https://lore.kernel.org/r/20200511160631.173205.54184.stgit@awfm-01.aw.intel.com Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com> Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Sadanand Warrier <sadanand.warrier@intel.com> Signed-off-by: Grzegorz Andrejczuk <grzegorz.andrejczuk@intel.com> Signed-off-by: Kaike Wan <kaike.wan@intel.com> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
80 lines
1.9 KiB
C
80 lines
1.9 KiB
C
// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
|
|
/*
|
|
* Copyright(c) 2020 Intel Corporation.
|
|
*
|
|
*/
|
|
|
|
/*
|
|
* This file contains HFI1 support for netdev RX functionality
|
|
*/
|
|
|
|
#include "sdma.h"
|
|
#include "verbs.h"
|
|
#include "netdev.h"
|
|
#include "hfi.h"
|
|
|
|
#include <linux/netdevice.h>
|
|
#include <linux/etherdevice.h>
|
|
#include <rdma/ib_verbs.h>
|
|
|
|
/**
|
|
* hfi1_netdev_add_data - Registers data with unique identifier
|
|
* to be requested later this is needed for VNIC and IPoIB VLANs
|
|
* implementations.
|
|
* This call is protected by mutex idr_lock.
|
|
*
|
|
* @dd: hfi1 dev data
|
|
* @id: requested integer id up to INT_MAX
|
|
* @data: data to be associated with index
|
|
*/
|
|
int hfi1_netdev_add_data(struct hfi1_devdata *dd, int id, void *data)
|
|
{
|
|
struct hfi1_netdev_priv *priv = hfi1_netdev_priv(dd->dummy_netdev);
|
|
|
|
return xa_insert(&priv->dev_tbl, id, data, GFP_NOWAIT);
|
|
}
|
|
|
|
/**
|
|
* hfi1_netdev_remove_data - Removes data with previously given id.
|
|
* Returns the reference to removed entry.
|
|
*
|
|
* @dd: hfi1 dev data
|
|
* @id: requested integer id up to INT_MAX
|
|
*/
|
|
void *hfi1_netdev_remove_data(struct hfi1_devdata *dd, int id)
|
|
{
|
|
struct hfi1_netdev_priv *priv = hfi1_netdev_priv(dd->dummy_netdev);
|
|
|
|
return xa_erase(&priv->dev_tbl, id);
|
|
}
|
|
|
|
/**
|
|
* hfi1_netdev_get_data - Gets data with given id
|
|
*
|
|
* @dd: hfi1 dev data
|
|
* @id: requested integer id up to INT_MAX
|
|
*/
|
|
void *hfi1_netdev_get_data(struct hfi1_devdata *dd, int id)
|
|
{
|
|
struct hfi1_netdev_priv *priv = hfi1_netdev_priv(dd->dummy_netdev);
|
|
|
|
return xa_load(&priv->dev_tbl, id);
|
|
}
|
|
|
|
/**
|
|
* hfi1_netdev_get_first_dat - Gets first entry with greater or equal id.
|
|
*
|
|
* @dd: hfi1 dev data
|
|
* @id: requested integer id up to INT_MAX
|
|
*/
|
|
void *hfi1_netdev_get_first_data(struct hfi1_devdata *dd, int *start_id)
|
|
{
|
|
struct hfi1_netdev_priv *priv = hfi1_netdev_priv(dd->dummy_netdev);
|
|
unsigned long index = *start_id;
|
|
void *ret;
|
|
|
|
ret = xa_find(&priv->dev_tbl, &index, UINT_MAX, XA_PRESENT);
|
|
*start_id = (int)index;
|
|
return ret;
|
|
}
|