aboutsummaryrefslogtreecommitdiffstats
path: root/net/caif
diff options
context:
space:
mode:
authorDmitry Tarnyagin <dmitry.tarnyagin@stericsson.com>2012-04-12 04:27:24 -0400
committerDavid S. Miller <davem@davemloft.net>2012-04-13 11:37:36 -0400
commit447648128ec22e294604674ffe1064aa3ec3b767 (patch)
tree1dfb671203f989a8612704674bbe59c78cf27109 /net/caif
parente65ac4d54546b7d7514a9e8be1484c758f2b7ba3 (diff)
caif: set traffic class for caif packets
Set traffic class for CAIF packets, based on socket priority, CAIF protocol type, or type of message. Traffic class mapping for different packet types: - control: TC_PRIO_CONTROL; - flow control: TC_PRIO_CONTROL; - at: TC_PRIO_CONTROL; - rfm: TC_PRIO_INTERACTIVE_BULK; - other sockets: equals to socket's TC; - network data: no change. Signed-off-by: Dmitry Tarnyagin <dmitry.tarnyagin@stericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/caif')
-rw-r--r--net/caif/caif_socket.c16
-rw-r--r--net/caif/cfctrl.c4
-rw-r--r--net/caif/cfpkt_skbuff.c7
-rw-r--r--net/caif/cfsrvl.c3
4 files changed, 28 insertions, 2 deletions
diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c
index 5016fa57b623..ce47ee9f48c8 100644
--- a/net/caif/caif_socket.c
+++ b/net/caif/caif_socket.c
@@ -19,7 +19,7 @@
19#include <linux/uaccess.h> 19#include <linux/uaccess.h>
20#include <linux/debugfs.h> 20#include <linux/debugfs.h>
21#include <linux/caif/caif_socket.h> 21#include <linux/caif/caif_socket.h>
22#include <linux/atomic.h> 22#include <linux/pkt_sched.h>
23#include <net/sock.h> 23#include <net/sock.h>
24#include <net/tcp_states.h> 24#include <net/tcp_states.h>
25#include <net/caif/caif_layer.h> 25#include <net/caif/caif_layer.h>
@@ -505,6 +505,7 @@ static int transmit_skb(struct sk_buff *skb, struct caifsock *cf_sk,
505 505
506 pkt = cfpkt_fromnative(CAIF_DIR_OUT, skb); 506 pkt = cfpkt_fromnative(CAIF_DIR_OUT, skb);
507 memset(skb->cb, 0, sizeof(struct caif_payload_info)); 507 memset(skb->cb, 0, sizeof(struct caif_payload_info));
508 cfpkt_set_prio(pkt, cf_sk->sk.sk_priority);
508 509
509 if (cf_sk->layer.dn == NULL) { 510 if (cf_sk->layer.dn == NULL) {
510 kfree_skb(skb); 511 kfree_skb(skb);
@@ -1062,6 +1063,18 @@ static int caif_create(struct net *net, struct socket *sock, int protocol,
1062 /* Store the protocol */ 1063 /* Store the protocol */
1063 sk->sk_protocol = (unsigned char) protocol; 1064 sk->sk_protocol = (unsigned char) protocol;
1064 1065
1066 /* Initialize default priority for well-known cases */
1067 switch (protocol) {
1068 case CAIFPROTO_AT:
1069 sk->sk_priority = TC_PRIO_CONTROL;
1070 break;
1071 case CAIFPROTO_RFM:
1072 sk->sk_priority = TC_PRIO_INTERACTIVE_BULK;
1073 break;
1074 default:
1075 sk->sk_priority = TC_PRIO_BESTEFFORT;
1076 }
1077
1065 /* 1078 /*
1066 * Lock in order to try to stop someone from opening the socket 1079 * Lock in order to try to stop someone from opening the socket
1067 * too early. 1080 * too early.
@@ -1081,7 +1094,6 @@ static int caif_create(struct net *net, struct socket *sock, int protocol,
1081 set_rx_flow_on(cf_sk); 1094 set_rx_flow_on(cf_sk);
1082 1095
1083 /* Set default options on configuration */ 1096 /* Set default options on configuration */
1084 cf_sk->sk.sk_priority = CAIF_PRIO_NORMAL;
1085 cf_sk->conn_req.link_selector = CAIF_LINK_LOW_LATENCY; 1097 cf_sk->conn_req.link_selector = CAIF_LINK_LOW_LATENCY;
1086 cf_sk->conn_req.protocol = protocol; 1098 cf_sk->conn_req.protocol = protocol;
1087 release_sock(&cf_sk->sk); 1099 release_sock(&cf_sk->sk);
diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
index 5cf52225692e..047cd0eec022 100644
--- a/net/caif/cfctrl.c
+++ b/net/caif/cfctrl.c
@@ -9,6 +9,7 @@
9#include <linux/stddef.h> 9#include <linux/stddef.h>
10#include <linux/spinlock.h> 10#include <linux/spinlock.h>
11#include <linux/slab.h> 11#include <linux/slab.h>
12#include <linux/pkt_sched.h>
12#include <net/caif/caif_layer.h> 13#include <net/caif/caif_layer.h>
13#include <net/caif/cfpkt.h> 14#include <net/caif/cfpkt.h>
14#include <net/caif/cfctrl.h> 15#include <net/caif/cfctrl.h>
@@ -189,6 +190,7 @@ void cfctrl_enum_req(struct cflayer *layer, u8 physlinkid)
189 cfctrl->serv.dev_info.id = physlinkid; 190 cfctrl->serv.dev_info.id = physlinkid;
190 cfpkt_addbdy(pkt, CFCTRL_CMD_ENUM); 191 cfpkt_addbdy(pkt, CFCTRL_CMD_ENUM);
191 cfpkt_addbdy(pkt, physlinkid); 192 cfpkt_addbdy(pkt, physlinkid);
193 cfpkt_set_prio(pkt, TC_PRIO_CONTROL);
192 dn->transmit(dn, pkt); 194 dn->transmit(dn, pkt);
193} 195}
194 196
@@ -281,6 +283,7 @@ int cfctrl_linkup_request(struct cflayer *layer,
281 * might arrive with the newly allocated channel ID. 283 * might arrive with the newly allocated channel ID.
282 */ 284 */
283 cfpkt_info(pkt)->dev_info->id = param->phyid; 285 cfpkt_info(pkt)->dev_info->id = param->phyid;
286 cfpkt_set_prio(pkt, TC_PRIO_CONTROL);
284 ret = 287 ret =
285 dn->transmit(dn, pkt); 288 dn->transmit(dn, pkt);
286 if (ret < 0) { 289 if (ret < 0) {
@@ -314,6 +317,7 @@ int cfctrl_linkdown_req(struct cflayer *layer, u8 channelid,
314 cfpkt_addbdy(pkt, CFCTRL_CMD_LINK_DESTROY); 317 cfpkt_addbdy(pkt, CFCTRL_CMD_LINK_DESTROY);
315 cfpkt_addbdy(pkt, channelid); 318 cfpkt_addbdy(pkt, channelid);
316 init_info(cfpkt_info(pkt), cfctrl); 319 init_info(cfpkt_info(pkt), cfctrl);
320 cfpkt_set_prio(pkt, TC_PRIO_CONTROL);
317 ret = 321 ret =
318 dn->transmit(dn, pkt); 322 dn->transmit(dn, pkt);
319#ifndef CAIF_NO_LOOP 323#ifndef CAIF_NO_LOOP
diff --git a/net/caif/cfpkt_skbuff.c b/net/caif/cfpkt_skbuff.c
index e335ba859b97..863dedd91bb6 100644
--- a/net/caif/cfpkt_skbuff.c
+++ b/net/caif/cfpkt_skbuff.c
@@ -381,6 +381,7 @@ struct cfpkt *cfpkt_split(struct cfpkt *pkt, u16 pos)
381 memcpy(skb2->data, split, len2nd); 381 memcpy(skb2->data, split, len2nd);
382 skb2->tail += len2nd; 382 skb2->tail += len2nd;
383 skb2->len += len2nd; 383 skb2->len += len2nd;
384 skb2->priority = skb->priority;
384 return skb_to_pkt(skb2); 385 return skb_to_pkt(skb2);
385} 386}
386 387
@@ -394,3 +395,9 @@ struct caif_payload_info *cfpkt_info(struct cfpkt *pkt)
394 return (struct caif_payload_info *)&pkt_to_skb(pkt)->cb; 395 return (struct caif_payload_info *)&pkt_to_skb(pkt)->cb;
395} 396}
396EXPORT_SYMBOL(cfpkt_info); 397EXPORT_SYMBOL(cfpkt_info);
398
399void cfpkt_set_prio(struct cfpkt *pkt, int prio)
400{
401 pkt_to_skb(pkt)->priority = prio;
402}
403EXPORT_SYMBOL(cfpkt_set_prio);
diff --git a/net/caif/cfsrvl.c b/net/caif/cfsrvl.c
index 4aa33d4496b6..dd485f6128e8 100644
--- a/net/caif/cfsrvl.c
+++ b/net/caif/cfsrvl.c
@@ -11,6 +11,7 @@
11#include <linux/errno.h> 11#include <linux/errno.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/pkt_sched.h>
14#include <net/caif/caif_layer.h> 15#include <net/caif/caif_layer.h>
15#include <net/caif/cfsrvl.h> 16#include <net/caif/cfsrvl.h>
16#include <net/caif/cfpkt.h> 17#include <net/caif/cfpkt.h>
@@ -120,6 +121,7 @@ static int cfservl_modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl)
120 info->channel_id = service->layer.id; 121 info->channel_id = service->layer.id;
121 info->hdr_len = 1; 122 info->hdr_len = 1;
122 info->dev_info = &service->dev_info; 123 info->dev_info = &service->dev_info;
124 cfpkt_set_prio(pkt, TC_PRIO_CONTROL);
123 return layr->dn->transmit(layr->dn, pkt); 125 return layr->dn->transmit(layr->dn, pkt);
124 } 126 }
125 case CAIF_MODEMCMD_FLOW_OFF_REQ: 127 case CAIF_MODEMCMD_FLOW_OFF_REQ:
@@ -140,6 +142,7 @@ static int cfservl_modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl)
140 info->channel_id = service->layer.id; 142 info->channel_id = service->layer.id;
141 info->hdr_len = 1; 143 info->hdr_len = 1;
142 info->dev_info = &service->dev_info; 144 info->dev_info = &service->dev_info;
145 cfpkt_set_prio(pkt, TC_PRIO_CONTROL);
143 return layr->dn->transmit(layr->dn, pkt); 146 return layr->dn->transmit(layr->dn, pkt);
144 } 147 }
145 default: 148 default: