@@ -106,6 +106,16 @@ typedef struct {
#endif
} socket_lock_t;
+struct dev_and_queue {
+ union {
+ struct {
+ int ifindex;
+ u16 queue;
+ };
+ u64 val64;
+ };
+};
+
struct sock;
struct proto;
struct net;
@@ -1788,6 +1798,50 @@ static inline int sk_receive_skb(struct sock *sk, struct sk_buff *skb,
return __sk_receive_skb(sk, skb, nested, 1, true);
}
+#define NO_QUEUE_MAPPING USHRT_MAX
+
+static inline void __dev_and_queue_get(const struct dev_and_queue *idandq,
+ int *ifindex, int *queue)
+{
+ struct dev_and_queue dandq;
+
+ dandq.val64 = idandq->val64;
+
+ if (dandq.ifindex >= 0 && dandq.queue != NO_QUEUE_MAPPING) {
+ *ifindex = dandq.ifindex;
+ *queue = dandq.queue;
+ return;
+ }
+
+ *ifindex = -1;
+ *queue = -1;
+}
+
+static inline void __dev_and_queue_set(struct dev_and_queue *odandq,
+ struct net_device *dev, int queue)
+{
+ struct dev_and_queue dandq;
+
+ /* queue_mapping accept only upto a 16-bit value */
+ if (WARN_ON_ONCE((unsigned short)queue >= USHRT_MAX))
+ return;
+
+ dandq.ifindex = dev->ifindex;
+ dandq.queue = queue;
+
+ odandq->val64 = dandq.val64;
+}
+
+static inline void __dev_and_queue_clear(struct dev_and_queue *odandq)
+{
+ struct dev_and_queue dandq;
+
+ dandq.ifindex = -1;
+ dandq.queue = NO_QUEUE_MAPPING;
+
+ odandq->val64 = dandq.val64;
+}
+
static inline void sk_tx_queue_set(struct sock *sk, int tx_queue)
{
/* sk_tx_queue_mapping accept only upto a 16-bit value */
@@ -1796,8 +1850,6 @@ static inline void sk_tx_queue_set(struct sock *sk, int tx_queue)
sk->sk_tx_queue_mapping = tx_queue;
}
-#define NO_QUEUE_MAPPING USHRT_MAX
-
static inline void sk_tx_queue_clear(struct sock *sk)
{
sk->sk_tx_queue_mapping = NO_QUEUE_MAPPING;