Skip to content

Commit

Permalink
nfp: add support for sending control messages via mailbox
Browse files Browse the repository at this point in the history
FW may prefer to handle some communication via a mailbox
or the vNIC may simply not have a control queue (VFs).
Add a way of exchanging ccm-compatible messages via a
mailbox.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jakub Kicinski authored and David S. Miller committed Jun 6, 2019
1 parent a686348 commit d3e4dfe
Show file tree
Hide file tree
Showing 7 changed files with 646 additions and 8 deletions.
1 change: 1 addition & 0 deletions drivers/net/ethernet/netronome/nfp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ nfp-objs := \
nfpcore/nfp_rtsym.o \
nfpcore/nfp_target.o \
ccm.o \
ccm_mbox.o \
nfp_asm.o \
nfp_app.o \
nfp_app_nic.o \
Expand Down
3 changes: 0 additions & 3 deletions drivers/net/ethernet/netronome/nfp/ccm.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
#include "nfp_app.h"
#include "nfp_net.h"

#define NFP_CCM_TYPE_REPLY_BIT 7
#define __NFP_CCM_REPLY(req) (BIT(NFP_CCM_TYPE_REPLY_BIT) | (req))

#define ccm_warn(app, msg...) nn_dp_warn(&(app)->ctrl->dp, msg)

#define NFP_CCM_TAG_ALLOC_SPAN (U16_MAX / 4)
Expand Down
44 changes: 39 additions & 5 deletions drivers/net/ethernet/netronome/nfp/ccm.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/wait.h>

struct nfp_app;
struct nfp_net;

/* Firmware ABI */

Expand All @@ -26,10 +27,18 @@ enum nfp_ccm_type {

#define NFP_CCM_ABI_VERSION 1

#define NFP_CCM_TYPE_REPLY_BIT 7
#define __NFP_CCM_REPLY(req) (BIT(NFP_CCM_TYPE_REPLY_BIT) | (req))

struct nfp_ccm_hdr {
u8 type;
u8 ver;
__be16 tag;
union {
struct {
u8 type;
u8 ver;
__be16 tag;
};
__be32 raw;
};
};

static inline u8 nfp_ccm_get_type(struct sk_buff *skb)
Expand All @@ -41,15 +50,31 @@ static inline u8 nfp_ccm_get_type(struct sk_buff *skb)
return hdr->type;
}

static inline unsigned int nfp_ccm_get_tag(struct sk_buff *skb)
static inline __be16 __nfp_ccm_get_tag(struct sk_buff *skb)
{
struct nfp_ccm_hdr *hdr;

hdr = (struct nfp_ccm_hdr *)skb->data;

return be16_to_cpu(hdr->tag);
return hdr->tag;
}

static inline unsigned int nfp_ccm_get_tag(struct sk_buff *skb)
{
return be16_to_cpu(__nfp_ccm_get_tag(skb));
}

#define NFP_NET_MBOX_TLV_TYPE GENMASK(31, 16)
#define NFP_NET_MBOX_TLV_LEN GENMASK(15, 0)

enum nfp_ccm_mbox_tlv_type {
NFP_NET_MBOX_TLV_TYPE_UNKNOWN = 0,
NFP_NET_MBOX_TLV_TYPE_END = 1,
NFP_NET_MBOX_TLV_TYPE_MSG = 2,
NFP_NET_MBOX_TLV_TYPE_MSG_NOSUP = 3,
NFP_NET_MBOX_TLV_TYPE_RESV = 4,
};

/* Implementation */

/**
Expand Down Expand Up @@ -80,4 +105,13 @@ void nfp_ccm_rx(struct nfp_ccm *ccm, struct sk_buff *skb);
struct sk_buff *
nfp_ccm_communicate(struct nfp_ccm *ccm, struct sk_buff *skb,
enum nfp_ccm_type type, unsigned int reply_size);

bool nfp_ccm_mbox_fits(struct nfp_net *nn, unsigned int size);
struct sk_buff *
nfp_ccm_mbox_alloc(struct nfp_net *nn, unsigned int req_size,
unsigned int reply_size, gfp_t flags);
int nfp_ccm_mbox_communicate(struct nfp_net *nn, struct sk_buff *skb,
enum nfp_ccm_type type,
unsigned int reply_size,
unsigned int max_reply_size);
#endif
Loading

0 comments on commit d3e4dfe

Please sign in to comment.