mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-24 01:41:39 +00:00
![Mike Marciniszyn](/assets/img/avatar_default.png)
The following allocation with large txqueuelen will result in the
following warning:
Call Trace:
__alloc_pages_nodemask+0x283/0x2c0
kmalloc_large_node+0x3c/0xa0
__kmalloc_node+0x22a/0x2f0
hfi1_ipoib_txreq_init+0x19f/0x330 [hfi1]
hfi1_ipoib_setup_rn+0xd3/0x1a0 [hfi1]
rdma_init_netdev+0x5a/0x80 [ib_core]
ipoib_intf_init+0x6c/0x350 [ib_ipoib]
ipoib_intf_alloc+0x5c/0xc0 [ib_ipoib]
ipoib_add_one+0xbe/0x300 [ib_ipoib]
add_client_context+0x12c/0x1a0 [ib_core]
ib_register_client+0x147/0x190 [ib_core]
ipoib_init_module+0xdd/0x132 [ib_ipoib]
do_one_initcall+0x46/0x1c3
do_init_module+0x5a/0x220
load_module+0x14c5/0x17f0
__do_sys_init_module+0x13b/0x180
do_syscall_64+0x5b/0x1a0
entry_SYSCALL_64_after_hwframe+0x65/0xca
For ipoib, the txqueuelen is modified with the module parameter
send_queue_size.
Fix by changing to use kv versions of the same allocator to handle the
large allocations. The allocation embeds a hdr struct that is dma mapped.
Change that struct to a pointer to a kzalloced struct.
Cc: stable@vger.kernel.org
Fixes: d99dc602e2
("IB/hfi1: Add functions to transmit datagram ipoib packets")
Link: https://lore.kernel.org/r/1642287756-182313-3-git-send-email-mike.marciniszyn@cornelisnetworks.com
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
171 lines
4.3 KiB
C
171 lines
4.3 KiB
C
/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
|
|
/*
|
|
* Copyright(c) 2020 Intel Corporation.
|
|
*
|
|
*/
|
|
|
|
/*
|
|
* This file contains HFI1 support for IPOIB functionality
|
|
*/
|
|
|
|
#ifndef HFI1_IPOIB_H
|
|
#define HFI1_IPOIB_H
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/stddef.h>
|
|
#include <linux/atomic.h>
|
|
#include <linux/netdevice.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/skbuff.h>
|
|
#include <linux/list.h>
|
|
#include <linux/if_infiniband.h>
|
|
|
|
#include "hfi.h"
|
|
#include "iowait.h"
|
|
#include "netdev.h"
|
|
|
|
#include <rdma/ib_verbs.h>
|
|
|
|
#define HFI1_IPOIB_ENTROPY_SHIFT 24
|
|
|
|
#define HFI1_IPOIB_TXREQ_NAME_LEN 32
|
|
|
|
#define HFI1_IPOIB_PSEUDO_LEN 20
|
|
#define HFI1_IPOIB_ENCAP_LEN 4
|
|
|
|
struct hfi1_ipoib_dev_priv;
|
|
|
|
union hfi1_ipoib_flow {
|
|
u16 as_int;
|
|
struct {
|
|
u8 tx_queue;
|
|
u8 sc5;
|
|
} __attribute__((__packed__));
|
|
};
|
|
|
|
/**
|
|
* struct ipoib_txreq - IPOIB transmit descriptor
|
|
* @txreq: sdma transmit request
|
|
* @sdma_hdr: 9b ib headers
|
|
* @sdma_status: status returned by sdma engine
|
|
* @complete: non-zero implies complete
|
|
* @priv: ipoib netdev private data
|
|
* @txq: txq on which skb was output
|
|
* @skb: skb to send
|
|
*/
|
|
struct ipoib_txreq {
|
|
struct sdma_txreq txreq;
|
|
struct hfi1_sdma_header *sdma_hdr;
|
|
int sdma_status;
|
|
int complete;
|
|
struct hfi1_ipoib_dev_priv *priv;
|
|
struct hfi1_ipoib_txq *txq;
|
|
struct sk_buff *skb;
|
|
};
|
|
|
|
/**
|
|
* struct hfi1_ipoib_circ_buf - List of items to be processed
|
|
* @items: ring of items each a power of two size
|
|
* @max_items: max items + 1 that the ring can contain
|
|
* @shift: log2 of size for getting txreq
|
|
* @sent_txreqs: count of txreqs posted to sdma
|
|
* @tail: ring tail
|
|
* @stops: count of stops of queue
|
|
* @ring_full: ring has been filled
|
|
* @no_desc: descriptor shortage seen
|
|
* @complete_txreqs: count of txreqs completed by sdma
|
|
* @head: ring head
|
|
*/
|
|
struct hfi1_ipoib_circ_buf {
|
|
void *items;
|
|
u32 max_items;
|
|
u32 shift;
|
|
/* consumer cache line */
|
|
u64 ____cacheline_aligned_in_smp sent_txreqs;
|
|
u32 avail;
|
|
u32 tail;
|
|
atomic_t stops;
|
|
atomic_t ring_full;
|
|
atomic_t no_desc;
|
|
/* producer cache line */
|
|
u64 ____cacheline_aligned_in_smp complete_txreqs;
|
|
u32 head;
|
|
};
|
|
|
|
/**
|
|
* struct hfi1_ipoib_txq - IPOIB per Tx queue information
|
|
* @priv: private pointer
|
|
* @sde: sdma engine
|
|
* @tx_list: tx request list
|
|
* @sent_txreqs: count of txreqs posted to sdma
|
|
* @flow: tracks when list needs to be flushed for a flow change
|
|
* @q_idx: ipoib Tx queue index
|
|
* @pkts_sent: indicator packets have been sent from this queue
|
|
* @wait: iowait structure
|
|
* @napi: pointer to tx napi interface
|
|
* @tx_ring: ring of ipoib txreqs to be reaped by napi callback
|
|
*/
|
|
struct hfi1_ipoib_txq {
|
|
struct napi_struct napi;
|
|
struct hfi1_ipoib_dev_priv *priv;
|
|
struct sdma_engine *sde;
|
|
struct list_head tx_list;
|
|
union hfi1_ipoib_flow flow;
|
|
u8 q_idx;
|
|
bool pkts_sent;
|
|
struct iowait wait;
|
|
|
|
struct hfi1_ipoib_circ_buf ____cacheline_aligned_in_smp tx_ring;
|
|
};
|
|
|
|
struct hfi1_ipoib_dev_priv {
|
|
struct hfi1_devdata *dd;
|
|
struct net_device *netdev;
|
|
struct ib_device *device;
|
|
struct hfi1_ipoib_txq *txqs;
|
|
const struct net_device_ops *netdev_ops;
|
|
struct rvt_qp *qp;
|
|
u32 qkey;
|
|
u16 pkey;
|
|
u16 pkey_index;
|
|
u8 port_num;
|
|
};
|
|
|
|
/* hfi1 ipoib rdma netdev's private data structure */
|
|
struct hfi1_ipoib_rdma_netdev {
|
|
struct rdma_netdev rn; /* keep this first */
|
|
/* followed by device private data */
|
|
struct hfi1_ipoib_dev_priv dev_priv;
|
|
};
|
|
|
|
static inline struct hfi1_ipoib_dev_priv *
|
|
hfi1_ipoib_priv(const struct net_device *dev)
|
|
{
|
|
return &((struct hfi1_ipoib_rdma_netdev *)netdev_priv(dev))->dev_priv;
|
|
}
|
|
|
|
int hfi1_ipoib_send(struct net_device *dev,
|
|
struct sk_buff *skb,
|
|
struct ib_ah *address,
|
|
u32 dqpn);
|
|
|
|
int hfi1_ipoib_txreq_init(struct hfi1_ipoib_dev_priv *priv);
|
|
void hfi1_ipoib_txreq_deinit(struct hfi1_ipoib_dev_priv *priv);
|
|
|
|
int hfi1_ipoib_rxq_init(struct net_device *dev);
|
|
void hfi1_ipoib_rxq_deinit(struct net_device *dev);
|
|
|
|
void hfi1_ipoib_napi_tx_enable(struct net_device *dev);
|
|
void hfi1_ipoib_napi_tx_disable(struct net_device *dev);
|
|
|
|
struct sk_buff *hfi1_ipoib_prepare_skb(struct hfi1_netdev_rxq *rxq,
|
|
int size, void *data);
|
|
|
|
int hfi1_ipoib_rn_get_params(struct ib_device *device,
|
|
u32 port_num,
|
|
enum rdma_netdev_t type,
|
|
struct rdma_netdev_alloc_params *params);
|
|
|
|
void hfi1_ipoib_tx_timeout(struct net_device *dev, unsigned int q);
|
|
|
|
#endif /* _IPOIB_H */
|