@@ -68,6 +68,8 @@ void rxe_mr_init_dma(int access, struct rxe_mr *mr);
int rxe_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length, u64 iova,
int access, struct rxe_mr *mr);
int rxe_mr_init_fast(int max_pages, struct rxe_mr *mr);
+int rxe_add_frag(struct sk_buff *skb, struct rxe_phys_buf *buf,
+ int length, int offset);
int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, int length,
enum rxe_mr_copy_op op);
int copy_data(struct rxe_pd *pd, int access, struct rxe_dma_info *dma,
@@ -286,6 +286,40 @@ void *iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length)
return addr;
}
+/**
+ * rxe_add_frag() - Add a frag to a nonlinear packet
+ * @skb: The packet buffer
+ * @buf: Kernel buffer info
+ * @length: Length of fragment
+ * @offset: Offset of fragment in buf
+ *
+ * Returns: 0 on success else a negative errno
+ */
+int rxe_add_frag(struct sk_buff *skb, struct rxe_phys_buf *buf,
+ int length, int offset)
+{
+ int nr_frags = skb_shinfo(skb)->nr_frags;
+ skb_frag_t *frag = &skb_shinfo(skb)->frags[nr_frags];
+
+ if (nr_frags >= MAX_SKB_FRAGS) {
+ pr_debug("%s: nr_frags (%d) >= MAX_SKB_FRAGS\n",
+ __func__, nr_frags);
+ return -EINVAL;
+ }
+
+ frag->bv_len = length;
+ frag->bv_offset = offset;
+ frag->bv_page = virt_to_page(buf->addr);
+ /* because kfree_skb will call put_page() */
+ get_page(frag->bv_page);
+ skb_shinfo(skb)->nr_frags++;
+
+ skb->data_len += length;
+ skb->len += length;
+
+ return 0;
+}
+
/* copy data from a range (vaddr, vaddr+length-1) to or from
* a mr object starting at iova.
*/
Add the subroutine rxe_add_frag() to add a fragment to an skb. This is in preparation for supporting fragmented skbs. Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com> --- drivers/infiniband/sw/rxe/rxe_loc.h | 2 ++ drivers/infiniband/sw/rxe/rxe_mr.c | 34 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)