Skip to content

Commit fea93ec

Browse files
Rémi Denis-Courmontdavem330
authored andcommitted
Phonet: zero-copy GPRS TX
Send aligned pipe payload if requested to do so. Then, the socket buffer needs not be fragmented anymore. Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent fc6a110 commit fea93ec

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

include/net/phonet/pep.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct pep_sock {
4444
u8 rx_fc; /* RX flow control */
4545
u8 tx_fc; /* TX flow control */
4646
u8 init_enable; /* auto-enable at creation */
47+
u8 aligned;
4748
};
4849

4950
static inline struct pep_sock *pep_sk(struct sock *sk)
@@ -139,6 +140,7 @@ enum {
139140
PN_PIPE_SB_NEGOTIATED_FC,
140141
PN_PIPE_SB_REQUIRED_FC_TX,
141142
PN_PIPE_SB_PREFERRED_FC_RX,
143+
PN_PIPE_SB_ALIGNED_DATA,
142144
};
143145

144146
/* Phonet pipe flow control models */

net/phonet/pep.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ static int pep_connreq_rcv(struct sock *sk, struct sk_buff *skb)
444444
struct sockaddr_pn dst;
445445
u16 peer_type;
446446
u8 pipe_handle, enabled, n_sb;
447+
u8 aligned = 0;
447448

448449
if (!pskb_pull(skb, sizeof(*hdr) + 4))
449450
return -EINVAL;
@@ -482,6 +483,9 @@ static int pep_connreq_rcv(struct sock *sk, struct sk_buff *skb)
482483
return -EINVAL;
483484
peer_type = (peer_type & 0xff00) | data[0];
484485
break;
486+
case PN_PIPE_SB_ALIGNED_DATA:
487+
aligned = data[0] != 0;
488+
break;
485489
}
486490
n_sb--;
487491
}
@@ -513,6 +517,7 @@ static int pep_connreq_rcv(struct sock *sk, struct sk_buff *skb)
513517
newpn->rx_credits = 0;
514518
newpn->rx_fc = newpn->tx_fc = PN_LEGACY_FLOW_CONTROL;
515519
newpn->init_enable = enabled;
520+
newpn->aligned = aligned;
516521

517522
BUG_ON(!skb_queue_empty(&newsk->sk_receive_queue));
518523
skb_queue_head(&newsk->sk_receive_queue, skb);
@@ -832,11 +837,15 @@ static int pipe_skb_send(struct sock *sk, struct sk_buff *skb)
832837
return -ENOBUFS;
833838
}
834839

835-
skb_push(skb, 3);
840+
skb_push(skb, 3 + pn->aligned);
836841
skb_reset_transport_header(skb);
837842
ph = pnp_hdr(skb);
838843
ph->utid = 0;
839-
ph->message_id = PNS_PIPE_DATA;
844+
if (pn->aligned) {
845+
ph->message_id = PNS_PIPE_ALIGNED_DATA;
846+
ph->data[0] = 0; /* padding */
847+
} else
848+
ph->message_id = PNS_PIPE_DATA;
840849
ph->pipe_handle = pn->pipe_handle;
841850

842851
return pn_skb_send(sk, skb, &pipe_srv);
@@ -930,6 +939,9 @@ int pep_write(struct sock *sk, struct sk_buff *skb)
930939
struct sk_buff *rskb, *fs;
931940
int flen = 0;
932941

942+
if (pep_sk(sk)->aligned)
943+
return pipe_skb_send(sk, skb);
944+
933945
rskb = alloc_skb(MAX_PNPIPE_HEADER, GFP_ATOMIC);
934946
if (!rskb) {
935947
kfree_skb(skb);

0 commit comments

Comments
 (0)