mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 22:51:42 +00:00
net/mlx5: FPGA, Add high-speed connection routines
An FPGA high-speed connection has two endpoints, an FPGA QP and a ConnectX QP. Add library routines to create and connect the endpoints of an FPGA high-speed connection. These routines allow creating and interacting with both types of connections: Shell and Sandbox Unit (SBU). Shell connection provides an interface to the FPGA's address space, which includes the configuration space and the DDR. Use of the shell connection will be introduced in a later patchset. SBU connection provides a command and/or data interface to the application-specific logic within the FPGA. Use of the SBU connection will be introduced in a later patch in this patchset. Some struct definitions are added to a new header file sdk.h, which will be extended in later patches in the patchset. This header file will contain the in-kernel FPGA client driver API. Signed-off-by: Ilan Tayari <ilant@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
This commit is contained in:
parent
6062118d5c
commit
537a505741
@ -6,7 +6,7 @@ mlx5_core-y := main.o cmd.o debugfs.o fw.o eq.o uar.o pagealloc.o \
|
||||
mad.o transobj.o vport.o sriov.o fs_cmd.o fs_core.o \
|
||||
fs_counters.o rl.o lag.o dev.o lib/gid.o
|
||||
|
||||
mlx5_core-$(CONFIG_MLX5_FPGA) += fpga/cmd.o fpga/core.o
|
||||
mlx5_core-$(CONFIG_MLX5_FPGA) += fpga/cmd.o fpga/core.o fpga/conn.o
|
||||
|
||||
mlx5_core-$(CONFIG_MLX5_CORE_EN) += wq.o eswitch.o eswitch_offloads.o \
|
||||
en_main.o en_common.o en_fs.o en_ethtool.o en_tx.o \
|
||||
|
1042
drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
Normal file
1042
drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
Normal file
File diff suppressed because it is too large
Load Diff
96
drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.h
Normal file
96
drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.h
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
|
||||
*
|
||||
* This software is available to you under a choice of one of two
|
||||
* licenses. You may choose to be licensed under the terms of the GNU
|
||||
* General Public License (GPL) Version 2, available from the file
|
||||
* COPYING in the main directory of this source tree, or the
|
||||
* OpenIB.org BSD license below:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MLX5_FPGA_CONN_H__
|
||||
#define __MLX5_FPGA_CONN_H__
|
||||
|
||||
#include <linux/mlx5/cq.h>
|
||||
#include <linux/mlx5/qp.h>
|
||||
|
||||
#include "fpga/core.h"
|
||||
#include "fpga/sdk.h"
|
||||
#include "wq.h"
|
||||
|
||||
struct mlx5_fpga_conn {
|
||||
struct mlx5_fpga_device *fdev;
|
||||
|
||||
void (*recv_cb)(void *cb_arg, struct mlx5_fpga_dma_buf *buf);
|
||||
void *cb_arg;
|
||||
|
||||
/* FPGA QP */
|
||||
u32 fpga_qpc[MLX5_ST_SZ_DW(fpga_qpc)];
|
||||
u32 fpga_qpn;
|
||||
|
||||
/* CQ */
|
||||
struct {
|
||||
struct mlx5_cqwq wq;
|
||||
struct mlx5_frag_wq_ctrl wq_ctrl;
|
||||
struct mlx5_core_cq mcq;
|
||||
struct tasklet_struct tasklet;
|
||||
} cq;
|
||||
|
||||
/* QP */
|
||||
struct {
|
||||
bool active;
|
||||
int sgid_index;
|
||||
struct mlx5_wq_qp wq;
|
||||
struct mlx5_wq_ctrl wq_ctrl;
|
||||
struct mlx5_core_qp mqp;
|
||||
struct {
|
||||
spinlock_t lock; /* Protects all SQ state */
|
||||
unsigned int pc;
|
||||
unsigned int cc;
|
||||
unsigned int size;
|
||||
struct mlx5_fpga_dma_buf **bufs;
|
||||
struct list_head backlog;
|
||||
} sq;
|
||||
struct {
|
||||
unsigned int pc;
|
||||
unsigned int cc;
|
||||
unsigned int size;
|
||||
struct mlx5_fpga_dma_buf **bufs;
|
||||
} rq;
|
||||
} qp;
|
||||
};
|
||||
|
||||
int mlx5_fpga_conn_device_init(struct mlx5_fpga_device *fdev);
|
||||
void mlx5_fpga_conn_device_cleanup(struct mlx5_fpga_device *fdev);
|
||||
struct mlx5_fpga_conn *
|
||||
mlx5_fpga_conn_create(struct mlx5_fpga_device *fdev,
|
||||
struct mlx5_fpga_conn_attr *attr,
|
||||
enum mlx5_ifc_fpga_qp_type qp_type);
|
||||
void mlx5_fpga_conn_destroy(struct mlx5_fpga_conn *conn);
|
||||
int mlx5_fpga_conn_send(struct mlx5_fpga_conn *conn,
|
||||
struct mlx5_fpga_dma_buf *buf);
|
||||
|
||||
#endif /* __MLX5_FPGA_CONN_H__ */
|
@ -37,6 +37,7 @@
|
||||
#include "mlx5_core.h"
|
||||
#include "lib/mlx5.h"
|
||||
#include "fpga/core.h"
|
||||
#include "fpga/conn.h"
|
||||
|
||||
static const char *const mlx5_fpga_error_strings[] = {
|
||||
"Null Syndrome",
|
||||
@ -127,7 +128,17 @@ int mlx5_fpga_device_start(struct mlx5_core_dev *mdev)
|
||||
|
||||
max_num_qps = MLX5_CAP_FPGA(mdev, shell_caps.max_num_qps);
|
||||
err = mlx5_core_reserve_gids(mdev, max_num_qps);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
err = mlx5_fpga_conn_device_init(fdev);
|
||||
if (err)
|
||||
goto err_rsvd_gid;
|
||||
|
||||
goto out;
|
||||
|
||||
err_rsvd_gid:
|
||||
mlx5_core_unreserve_gids(mdev, max_num_qps);
|
||||
out:
|
||||
spin_lock_irqsave(&fdev->state_lock, flags);
|
||||
fdev->state = err ? MLX5_FPGA_STATUS_FAILURE : MLX5_FPGA_STATUS_SUCCESS;
|
||||
@ -173,6 +184,7 @@ void mlx5_fpga_device_stop(struct mlx5_core_dev *mdev)
|
||||
fdev->state = MLX5_FPGA_STATUS_NONE;
|
||||
spin_unlock_irqrestore(&fdev->state_lock, flags);
|
||||
|
||||
mlx5_fpga_conn_device_cleanup(fdev);
|
||||
max_num_qps = MLX5_CAP_FPGA(mdev, shell_caps.max_num_qps);
|
||||
mlx5_core_unreserve_gids(mdev, max_num_qps);
|
||||
}
|
||||
|
@ -44,6 +44,13 @@ struct mlx5_fpga_device {
|
||||
enum mlx5_fpga_status state;
|
||||
enum mlx5_fpga_image last_admin_image;
|
||||
enum mlx5_fpga_image last_oper_image;
|
||||
|
||||
/* QP Connection resources */
|
||||
struct {
|
||||
u32 pdn;
|
||||
struct mlx5_core_mkey mkey;
|
||||
struct mlx5_uars_page *uar;
|
||||
} conn_res;
|
||||
};
|
||||
|
||||
#define mlx5_fpga_dbg(__adev, format, ...) \
|
||||
|
106
drivers/net/ethernet/mellanox/mlx5/core/fpga/sdk.h
Normal file
106
drivers/net/ethernet/mellanox/mlx5/core/fpga/sdk.h
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
|
||||
*
|
||||
* This software is available to you under a choice of one of two
|
||||
* licenses. You may choose to be licensed under the terms of the GNU
|
||||
* General Public License (GPL) Version 2, available from the file
|
||||
* COPYING in the main directory of this source tree, or the
|
||||
* OpenIB.org BSD license below:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MLX5_FPGA_SDK_H
|
||||
#define MLX5_FPGA_SDK_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/dma-direction.h>
|
||||
|
||||
/**
|
||||
* DOC: Innova SDK
|
||||
* This header defines the in-kernel API for Innova FPGA client drivers.
|
||||
*/
|
||||
|
||||
struct mlx5_fpga_conn;
|
||||
struct mlx5_fpga_device;
|
||||
|
||||
/**
|
||||
* struct mlx5_fpga_dma_entry - A scatter-gather DMA entry
|
||||
*/
|
||||
struct mlx5_fpga_dma_entry {
|
||||
/** @data: Virtual address pointer to the data */
|
||||
void *data;
|
||||
/** @size: Size in bytes of the data */
|
||||
unsigned int size;
|
||||
/** @dma_addr: Private member. Physical DMA-mapped address of the data */
|
||||
dma_addr_t dma_addr;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mlx5_fpga_dma_buf - A packet buffer
|
||||
* May contain up to 2 scatter-gather data entries
|
||||
*/
|
||||
struct mlx5_fpga_dma_buf {
|
||||
/** @dma_dir: DMA direction */
|
||||
enum dma_data_direction dma_dir;
|
||||
/** @sg: Scatter-gather entries pointing to the data in memory */
|
||||
struct mlx5_fpga_dma_entry sg[2];
|
||||
/** @list: Item in SQ backlog, for TX packets */
|
||||
struct list_head list;
|
||||
/**
|
||||
* @complete: Completion routine, for TX packets
|
||||
* @conn: FPGA Connection this packet was sent to
|
||||
* @fdev: FPGA device this packet was sent to
|
||||
* @buf: The packet buffer
|
||||
* @status: 0 if successful, or an error code otherwise
|
||||
*/
|
||||
void (*complete)(struct mlx5_fpga_conn *conn,
|
||||
struct mlx5_fpga_device *fdev,
|
||||
struct mlx5_fpga_dma_buf *buf, u8 status);
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mlx5_fpga_conn_attr - FPGA connection attributes
|
||||
* Describes the attributes of a connection
|
||||
*/
|
||||
struct mlx5_fpga_conn_attr {
|
||||
/** @tx_size: Size of connection TX queue, in packets */
|
||||
unsigned int tx_size;
|
||||
/** @rx_size: Size of connection RX queue, in packets */
|
||||
unsigned int rx_size;
|
||||
/**
|
||||
* @recv_cb: Callback function which is called for received packets
|
||||
* @cb_arg: The value provided in mlx5_fpga_conn_attr.cb_arg
|
||||
* @buf: A buffer containing a received packet
|
||||
*
|
||||
* buf is guaranteed to only contain a single scatter-gather entry.
|
||||
* The size of the actual packet received is specified in buf.sg[0].size
|
||||
* When this callback returns, the packet buffer may be re-used for
|
||||
* subsequent receives.
|
||||
*/
|
||||
void (*recv_cb)(void *cb_arg, struct mlx5_fpga_dma_buf *buf);
|
||||
void *cb_arg;
|
||||
};
|
||||
|
||||
#endif /* MLX5_FPGA_SDK_H */
|
Loading…
Reference in New Issue
Block a user