]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
thunderbolt / net: Move ring_frame_size() to thunderbolt.h
authorMika Westerberg <mika.westerberg@linux.intel.com>
Mon, 10 Nov 2025 11:16:53 +0000 (13:16 +0200)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Tue, 19 May 2026 12:20:18 +0000 (14:20 +0200)
This function can be used outside of thunderbolt networking driver so
move it to the common header.

No functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/net/thunderbolt/main.c
include/linux/thunderbolt.h

index 7aae5d915a1ebc1c6ef6f686df3514cab796c009..495f7fe366e69681b150c6e84526bcaf1d39e891 100644 (file)
@@ -38,7 +38,7 @@
 #define TBNET_MATCH_FRAGS_ID   BIT(1)
 #define TBNET_64K_FRAMES       BIT(2)
 #define TBNET_MAX_MTU          SZ_64K
-#define TBNET_FRAME_SIZE       SZ_4K
+#define TBNET_FRAME_SIZE       TB_MAX_FRAME_SIZE
 #define TBNET_MAX_PAYLOAD_SIZE \
        (TBNET_FRAME_SIZE - sizeof(struct thunderbolt_ip_frame_header))
 /* Rx packets need to hold space for skb_shared_info */
@@ -327,11 +327,6 @@ static void stop_login(struct tbnet *net)
        netdev_dbg(net->dev, "login stopped\n");
 }
 
-static inline unsigned int tbnet_frame_size(const struct tbnet_frame *tf)
-{
-       return tf->frame.size ? : TBNET_FRAME_SIZE;
-}
-
 static void tbnet_free_buffers(struct tbnet_ring *ring)
 {
        unsigned int i;
@@ -562,7 +557,7 @@ static struct tbnet_frame *tbnet_get_tx_buffer(struct tbnet *net)
        tf->frame.size = 0;
 
        dma_sync_single_for_cpu(dma_dev, tf->frame.buffer_phy,
-                               tbnet_frame_size(tf), DMA_TO_DEVICE);
+                               tb_ring_frame_size(&tf->frame), DMA_TO_DEVICE);
 
        return tf;
 }
@@ -744,7 +739,7 @@ static bool tbnet_check_frame(struct tbnet *net, const struct tbnet_frame *tf,
        }
 
        /* Should be greater than just header i.e. contains data */
-       size = tbnet_frame_size(tf);
+       size = tb_ring_frame_size(&tf->frame);
        if (size <= sizeof(*hdr)) {
                net->stats.rx_length_errors++;
                return false;
@@ -1011,7 +1006,8 @@ static bool tbnet_xmit_csum_and_map(struct tbnet *net, struct sk_buff *skb,
                                                hdr->frame_index, hdr->frame_count);
                        dma_sync_single_for_device(dma_dev,
                                frames[i]->frame.buffer_phy,
-                               tbnet_frame_size(frames[i]), DMA_TO_DEVICE);
+                               tb_ring_frame_size(&frames[i]->frame),
+                                                  DMA_TO_DEVICE);
                }
 
                return true;
@@ -1085,7 +1081,7 @@ static bool tbnet_xmit_csum_and_map(struct tbnet *net, struct sk_buff *skb,
         */
        for (i = 0; i < frame_count; i++) {
                dma_sync_single_for_device(dma_dev, frames[i]->frame.buffer_phy,
-                       tbnet_frame_size(frames[i]), DMA_TO_DEVICE);
+                       tb_ring_frame_size(&frames[i]->frame), DMA_TO_DEVICE);
        }
 
        return true;
index f60e3a1aecaed62b27bcc1646ad2dc56d0673991..1d1bd458b5afbc7ab428148c2152a0a826f51858 100644 (file)
@@ -628,7 +628,15 @@ struct ring_frame {
 };
 
 /* Minimum size for ring_rx */
-#define TB_FRAME_SIZE          0x100
+#define TB_FRAME_SIZE          256
+#define TB_MAX_FRAME_SIZE      4096
+
+static inline size_t tb_ring_frame_size(const struct ring_frame *frame)
+{
+       if (frame->size)
+               return frame->size;
+       return TB_MAX_FRAME_SIZE;
+}
 
 struct tb_ring *tb_ring_alloc_tx(struct tb_nhi *nhi, int hop, int size,
                                 unsigned int flags);