rxrpc: Do zerocopy using MSG_SPLICE_PAGES and page frags
[linux-2.6-block.git] / net / rxrpc / ar-internal.h
index 9ea4e7e9d9f753f91704764e3357613b5f0f622b..47f4689379ca2e702acde317fe4e3a59cf901c32 100644 (file)
@@ -248,10 +248,9 @@ struct rxrpc_security {
                                        struct rxrpc_key_token *);
 
        /* Work out how much data we can store in a packet, given an estimate
-        * of the amount of data remaining.
+        * of the amount of data remaining and allocate a data buffer.
         */
-       int (*how_much_data)(struct rxrpc_call *, size_t,
-                            size_t *, size_t *, size_t *);
+       struct rxrpc_txbuf *(*alloc_txbuf)(struct rxrpc_call *call, size_t remaining, gfp_t gfp);
 
        /* impose security on a packet */
        int (*secure_packet)(struct rxrpc_call *, struct rxrpc_txbuf *);
@@ -292,6 +291,7 @@ struct rxrpc_local {
        struct socket           *socket;        /* my UDP socket */
        struct task_struct      *io_thread;
        struct completion       io_thread_ready; /* Indication that the I/O thread started */
+       struct page_frag_cache  tx_alloc;       /* Tx control packet allocation (I/O thread only) */
        struct rxrpc_sock       *service;       /* Service(s) listening on this endpoint */
 #ifdef CONFIG_AF_RXRPC_INJECT_RX_DELAY
        struct sk_buff_head     rx_delay_queue; /* Delay injection queue */
@@ -500,6 +500,8 @@ struct rxrpc_connection {
        struct list_head        proc_link;      /* link in procfs list */
        struct list_head        link;           /* link in master connection list */
        struct sk_buff_head     rx_queue;       /* received conn-level packets */
+       struct page_frag_cache  tx_data_alloc;  /* Tx DATA packet allocation */
+       struct mutex            tx_data_alloc_lock;
 
        struct mutex            security_lock;  /* Lock for security management */
        const struct rxrpc_security *security;  /* applied security module */
@@ -788,7 +790,6 @@ struct rxrpc_send_params {
  * Buffer of data to be output as a packet.
  */
 struct rxrpc_txbuf {
-       struct rcu_head         rcu;
        struct list_head        call_link;      /* Link in call->tx_sendmsg/tx_buffer */
        struct list_head        tx_link;        /* Link in live Enc queue or Tx queue */
        ktime_t                 last_sent;      /* Time at which last transmitted */
@@ -806,22 +807,8 @@ struct rxrpc_txbuf {
        __be16                  cksum;          /* Checksum to go in header */
        unsigned short          ack_rwind;      /* ACK receive window */
        u8 /*enum rxrpc_propose_ack_trace*/ ack_why;    /* If ack, why */
-       u8                      nr_kvec;
-       struct kvec             kvec[1];
-       struct {
-               /* The packet for encrypting and DMA'ing.  We align it such
-                * that data[] aligns correctly for any crypto blocksize.
-                */
-               u8              pad[64 - sizeof(struct rxrpc_wire_header)];
-               struct rxrpc_wire_header _wire; /* Network-ready header */
-               union {
-                       u8      data[RXRPC_JUMBO_DATALEN]; /* Data packet */
-                       struct {
-                               struct rxrpc_ackpacket _ack;
-                               DECLARE_FLEX_ARRAY(u8, acks);
-                       };
-               };
-       } __aligned(64);
+       u8                      nr_kvec;        /* Amount of kvec[] used */
+       struct kvec             kvec[3];
 };
 
 static inline bool rxrpc_sending_to_server(const struct rxrpc_txbuf *txb)
@@ -1299,8 +1286,9 @@ static inline void rxrpc_sysctl_exit(void) {}
  * txbuf.c
  */
 extern atomic_t rxrpc_nr_txbuf;
-struct rxrpc_txbuf *rxrpc_alloc_txbuf(struct rxrpc_call *call, u8 packet_type,
-                                     gfp_t gfp);
+struct rxrpc_txbuf *rxrpc_alloc_data_txbuf(struct rxrpc_call *call, size_t data_size,
+                                          size_t data_align, gfp_t gfp);
+struct rxrpc_txbuf *rxrpc_alloc_ack_txbuf(struct rxrpc_call *call, size_t sack_size);
 void rxrpc_get_txbuf(struct rxrpc_txbuf *txb, enum rxrpc_txbuf_trace what);
 void rxrpc_see_txbuf(struct rxrpc_txbuf *txb, enum rxrpc_txbuf_trace what);
 void rxrpc_put_txbuf(struct rxrpc_txbuf *txb, enum rxrpc_txbuf_trace what);