Skip to content

Commit

Permalink
Merge tag 'for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…git/dledford/rdma

Pull more rdma updates from Doug Ledford:
 "Minor updates for rxe driver"

[ Starting to do merge window pulls again - the current -git tree does
  appear to have some netfilter use-after-free issues, but I've sent
  off the report to the proper channels, and I don't want to delay merge
  window activity any more ]

* tag 'for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma:
  IB/rxe: improved debug prints & code cleanup
  rdma_rxe: Ensure rdma_rxe init occurs at correct time
  IB/rxe: Properly honor max IRD value for rd/atomic.
  IB/{rxe,core,rdmavt}: Fix kernel crash for reg MR
  IB/rxe: Fix sending out loopback packet on netdev interface.
  IB/rxe: Avoid scheduling tasklet for userspace QP
  • Loading branch information
Linus Torvalds committed Oct 9, 2016
2 parents b66484c + e404f94 commit 1fde76f
Show file tree
Hide file tree
Showing 18 changed files with 210 additions and 124 deletions.
17 changes: 17 additions & 0 deletions drivers/infiniband/sw/rdmavt/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@ static void rvt_unmap_sg(struct ib_device *dev,
/* This is a stub, nothing to be done here */
}

static int rvt_map_sg_attrs(struct ib_device *dev, struct scatterlist *sgl,
int nents, enum dma_data_direction direction,
unsigned long attrs)
{
return rvt_map_sg(dev, sgl, nents, direction);
}

static void rvt_unmap_sg_attrs(struct ib_device *dev,
struct scatterlist *sg, int nents,
enum dma_data_direction direction,
unsigned long attrs)
{
return rvt_unmap_sg(dev, sg, nents, direction);
}

static void rvt_sync_single_for_cpu(struct ib_device *dev, u64 addr,
size_t size, enum dma_data_direction dir)
{
Expand Down Expand Up @@ -177,6 +192,8 @@ struct ib_dma_mapping_ops rvt_default_dma_mapping_ops = {
.unmap_page = rvt_dma_unmap_page,
.map_sg = rvt_map_sg,
.unmap_sg = rvt_unmap_sg,
.map_sg_attrs = rvt_map_sg_attrs,
.unmap_sg_attrs = rvt_unmap_sg_attrs,
.sync_single_for_cpu = rvt_sync_single_for_cpu,
.sync_single_for_device = rvt_sync_single_for_device,
.alloc_coherent = rvt_dma_alloc_coherent,
Expand Down
36 changes: 7 additions & 29 deletions drivers/infiniband/sw/rxe/rxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,38 +358,16 @@ static int __init rxe_module_init(void)
/* initialize slab caches for managed objects */
err = rxe_cache_init();
if (err) {
pr_err("rxe: unable to init object pools\n");
pr_err("unable to init object pools\n");
return err;
}

err = rxe_net_ipv4_init();
if (err) {
pr_err("rxe: unable to init ipv4 tunnel\n");
rxe_cache_exit();
goto exit;
}

err = rxe_net_ipv6_init();
if (err) {
pr_err("rxe: unable to init ipv6 tunnel\n");
rxe_cache_exit();
goto exit;
}

err = register_netdevice_notifier(&rxe_net_notifier);
if (err) {
pr_err("rxe: Failed to rigister netdev notifier\n");
goto exit;
}

pr_info("rxe: loaded\n");
err = rxe_net_init();
if (err)
return err;

pr_info("loaded\n");
return 0;

exit:
rxe_release_udp_tunnel(recv_sockets.sk4);
rxe_release_udp_tunnel(recv_sockets.sk6);
return err;
}

static void __exit rxe_module_exit(void)
Expand All @@ -398,8 +376,8 @@ static void __exit rxe_module_exit(void)
rxe_net_exit();
rxe_cache_exit();

pr_info("rxe: unloaded\n");
pr_info("unloaded\n");
}

module_init(rxe_module_init);
late_initcall(rxe_module_init);
module_exit(rxe_module_exit);
5 changes: 5 additions & 0 deletions drivers/infiniband/sw/rxe/rxe.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
#ifndef RXE_H
#define RXE_H

#ifdef pr_fmt
#undef pr_fmt
#endif
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/crc32.h>
Expand Down
4 changes: 2 additions & 2 deletions drivers/infiniband/sw/rxe/rxe_av.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ int rxe_av_chk_attr(struct rxe_dev *rxe, struct ib_ah_attr *attr)
struct rxe_port *port;

if (attr->port_num != 1) {
pr_info("rxe: invalid port_num = %d\n", attr->port_num);
pr_info("invalid port_num = %d\n", attr->port_num);
return -EINVAL;
}

port = &rxe->port;

if (attr->ah_flags & IB_AH_GRH) {
if (attr->grh.sgid_index > port->attr.gid_tbl_len) {
pr_info("rxe: invalid sgid index = %d\n",
pr_info("invalid sgid index = %d\n",
attr->grh.sgid_index);
return -EINVAL;
}
Expand Down
6 changes: 4 additions & 2 deletions drivers/infiniband/sw/rxe/rxe_comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,8 @@ int rxe_completer(void *arg)
state = COMPST_GET_ACK;

while (1) {
pr_debug("state = %s\n", comp_state_name[state]);
pr_debug("qp#%d state = %s\n", qp_num(qp),
comp_state_name[state]);
switch (state) {
case COMPST_GET_ACK:
skb = skb_dequeue(&qp->resp_pkts);
Expand Down Expand Up @@ -709,7 +710,8 @@ int rxe_completer(void *arg)
qp->comp.rnr_retry--;

qp->req.need_retry = 1;
pr_debug("set rnr nak timer\n");
pr_debug("qp#%d set rnr nak timer\n",
qp_num(qp));
mod_timer(&qp->rnr_nak_timer,
jiffies + rnrnak_jiffies(aeth_syn(pkt)
& ~AETH_TYPE_MASK));
Expand Down
17 changes: 17 additions & 0 deletions drivers/infiniband/sw/rxe/rxe_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ static void rxe_unmap_sg(struct ib_device *dev,
WARN_ON(!valid_dma_direction(direction));
}

static int rxe_map_sg_attrs(struct ib_device *dev, struct scatterlist *sgl,
int nents, enum dma_data_direction direction,
unsigned long attrs)
{
return rxe_map_sg(dev, sgl, nents, direction);
}

static void rxe_unmap_sg_attrs(struct ib_device *dev,
struct scatterlist *sg, int nents,
enum dma_data_direction direction,
unsigned long attrs)
{
rxe_unmap_sg(dev, sg, nents, direction);
}

static void rxe_sync_single_for_cpu(struct ib_device *dev,
u64 addr,
size_t size, enum dma_data_direction dir)
Expand Down Expand Up @@ -159,6 +174,8 @@ struct ib_dma_mapping_ops rxe_dma_mapping_ops = {
.unmap_page = rxe_dma_unmap_page,
.map_sg = rxe_map_sg,
.unmap_sg = rxe_unmap_sg,
.map_sg_attrs = rxe_map_sg_attrs,
.unmap_sg_attrs = rxe_unmap_sg_attrs,
.sync_single_for_cpu = rxe_sync_single_for_cpu,
.sync_single_for_device = rxe_sync_single_for_device,
.alloc_coherent = rxe_dma_alloc_coherent,
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/sw/rxe/rxe_loc.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void free_rd_atomic_resource(struct rxe_qp *qp, struct resp_res *res);
static inline void rxe_advance_resp_resource(struct rxe_qp *qp)
{
qp->resp.res_head++;
if (unlikely(qp->resp.res_head == qp->attr.max_rd_atomic))
if (unlikely(qp->resp.res_head == qp->attr.max_dest_rd_atomic))
qp->resp.res_head = 0;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/sw/rxe/rxe_mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ int rxe_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)

ret = remap_vmalloc_range(vma, ip->obj, 0);
if (ret) {
pr_err("rxe: err %d from remap_vmalloc_range\n", ret);
pr_err("err %d from remap_vmalloc_range\n", ret);
goto done;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/sw/rxe/rxe_mr.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
static u8 rxe_get_key(void)
{
static unsigned key = 1;
static u32 key = 1;

key = key << 1;

Expand Down
51 changes: 36 additions & 15 deletions drivers/infiniband/sw/rxe/rxe_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct rxe_dev *net_to_rxe(struct net_device *ndev)
return found;
}

struct rxe_dev *get_rxe_by_name(const char* name)
struct rxe_dev *get_rxe_by_name(const char *name)
{
struct rxe_dev *rxe;
struct rxe_dev *found = NULL;
Expand Down Expand Up @@ -350,14 +350,14 @@ static void prepare_ipv6_hdr(struct dst_entry *dst, struct sk_buff *skb,
ip6h->payload_len = htons(skb->len - sizeof(*ip6h));
}

static int prepare4(struct rxe_dev *rxe, struct sk_buff *skb, struct rxe_av *av)
static int prepare4(struct rxe_dev *rxe, struct rxe_pkt_info *pkt,
struct sk_buff *skb, struct rxe_av *av)
{
struct dst_entry *dst;
bool xnet = false;
__be16 df = htons(IP_DF);
struct in_addr *saddr = &av->sgid_addr._sockaddr_in.sin_addr;
struct in_addr *daddr = &av->dgid_addr._sockaddr_in.sin_addr;
struct rxe_pkt_info *pkt = SKB_TO_PKT(skb);

dst = rxe_find_route4(rxe->ndev, saddr, daddr);
if (!dst) {
Expand All @@ -376,12 +376,12 @@ static int prepare4(struct rxe_dev *rxe, struct sk_buff *skb, struct rxe_av *av)
return 0;
}

static int prepare6(struct rxe_dev *rxe, struct sk_buff *skb, struct rxe_av *av)
static int prepare6(struct rxe_dev *rxe, struct rxe_pkt_info *pkt,
struct sk_buff *skb, struct rxe_av *av)
{
struct dst_entry *dst;
struct in6_addr *saddr = &av->sgid_addr._sockaddr_in6.sin6_addr;
struct in6_addr *daddr = &av->dgid_addr._sockaddr_in6.sin6_addr;
struct rxe_pkt_info *pkt = SKB_TO_PKT(skb);

dst = rxe_find_route6(rxe->ndev, saddr, daddr);
if (!dst) {
Expand All @@ -408,9 +408,9 @@ static int prepare(struct rxe_dev *rxe, struct rxe_pkt_info *pkt,
struct rxe_av *av = rxe_get_av(pkt);

if (av->network_type == RDMA_NETWORK_IPV4)
err = prepare4(rxe, skb, av);
err = prepare4(rxe, pkt, skb, av);
else if (av->network_type == RDMA_NETWORK_IPV6)
err = prepare6(rxe, skb, av);
err = prepare6(rxe, pkt, skb, av);

*crc = rxe_icrc_hdr(pkt, skb);

Expand Down Expand Up @@ -601,8 +601,7 @@ void rxe_port_up(struct rxe_dev *rxe)
port->attr.phys_state = IB_PHYS_STATE_LINK_UP;

rxe_port_event(rxe, IB_EVENT_PORT_ACTIVE);
pr_info("rxe: set %s active\n", rxe->ib_dev.name);
return;
pr_info("set %s active\n", rxe->ib_dev.name);
}

/* Caller must hold net_info_lock */
Expand All @@ -615,8 +614,7 @@ void rxe_port_down(struct rxe_dev *rxe)
port->attr.phys_state = IB_PHYS_STATE_LINK_DOWN;

rxe_port_event(rxe, IB_EVENT_PORT_ERR);
pr_info("rxe: set %s down\n", rxe->ib_dev.name);
return;
pr_info("set %s down\n", rxe->ib_dev.name);
}

static int rxe_notify(struct notifier_block *not_blk,
Expand All @@ -641,7 +639,7 @@ static int rxe_notify(struct notifier_block *not_blk,
rxe_port_down(rxe);
break;
case NETDEV_CHANGEMTU:
pr_info("rxe: %s changed mtu to %d\n", ndev->name, ndev->mtu);
pr_info("%s changed mtu to %d\n", ndev->name, ndev->mtu);
rxe_set_mtu(rxe, ndev->mtu);
break;
case NETDEV_REBOOT:
Expand All @@ -651,7 +649,7 @@ static int rxe_notify(struct notifier_block *not_blk,
case NETDEV_CHANGENAME:
case NETDEV_FEAT_CHANGE:
default:
pr_info("rxe: ignoring netdev event = %ld for %s\n",
pr_info("ignoring netdev event = %ld for %s\n",
event, ndev->name);
break;
}
Expand All @@ -671,7 +669,7 @@ int rxe_net_ipv4_init(void)
htons(ROCE_V2_UDP_DPORT), false);
if (IS_ERR(recv_sockets.sk4)) {
recv_sockets.sk4 = NULL;
pr_err("rxe: Failed to create IPv4 UDP tunnel\n");
pr_err("Failed to create IPv4 UDP tunnel\n");
return -1;
}

Expand All @@ -688,7 +686,7 @@ int rxe_net_ipv6_init(void)
htons(ROCE_V2_UDP_DPORT), true);
if (IS_ERR(recv_sockets.sk6)) {
recv_sockets.sk6 = NULL;
pr_err("rxe: Failed to create IPv6 UDP tunnel\n");
pr_err("Failed to create IPv6 UDP tunnel\n");
return -1;
}
#endif
Expand All @@ -701,3 +699,26 @@ void rxe_net_exit(void)
rxe_release_udp_tunnel(recv_sockets.sk4);
unregister_netdevice_notifier(&rxe_net_notifier);
}

int rxe_net_init(void)
{
int err;

recv_sockets.sk6 = NULL;

err = rxe_net_ipv4_init();
if (err)
return err;
err = rxe_net_ipv6_init();
if (err)
goto err_out;
err = register_netdevice_notifier(&rxe_net_notifier);
if (err) {
pr_err("Failed to register netdev notifier\n");
goto err_out;
}
return 0;
err_out:
rxe_net_exit();
return err;
}
3 changes: 1 addition & 2 deletions drivers/infiniband/sw/rxe/rxe_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ void rxe_release_udp_tunnel(struct socket *sk);

struct rxe_dev *rxe_net_add(struct net_device *ndev);

int rxe_net_ipv4_init(void);
int rxe_net_ipv6_init(void);
int rxe_net_init(void);
void rxe_net_exit(void);

#endif /* RXE_NET_H */
Loading

0 comments on commit 1fde76f

Please sign in to comment.