]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ionic: add a check for max SGs and SKB frags
authorShannon Nelson <shannon.nelson@amd.com>
Mon, 18 Sep 2023 22:21:35 +0000 (15:21 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 20 Sep 2023 09:52:31 +0000 (10:52 +0100)
Add a check of the queue's max_sg_elems against the maximum frags we
expect to see per SKB and take the smaller of the two as our max for
the queues' descriptor buffer allocations.

Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/pensando/ionic/ionic_lif.c

index 2c3e36b2dd7f24abafcb18ab87f280470762f849..edc14730ce88b5f7db438d37b4ad2e93da3cb813 100644 (file)
@@ -3831,6 +3831,18 @@ static void ionic_lif_queue_identify(struct ionic_lif *lif)
                        qtype, qti->max_sg_elems);
                dev_dbg(ionic->dev, " qtype[%d].sg_desc_stride = %d\n",
                        qtype, qti->sg_desc_stride);
+
+               if (qti->max_sg_elems >= IONIC_MAX_FRAGS) {
+                       qti->max_sg_elems = IONIC_MAX_FRAGS - 1;
+                       dev_dbg(ionic->dev, "limiting qtype %d max_sg_elems to IONIC_MAX_FRAGS-1 %d\n",
+                               qtype, qti->max_sg_elems);
+               }
+
+               if (qti->max_sg_elems > MAX_SKB_FRAGS) {
+                       qti->max_sg_elems = MAX_SKB_FRAGS;
+                       dev_dbg(ionic->dev, "limiting qtype %d max_sg_elems to MAX_SKB_FRAGS %d\n",
+                               qtype, qti->max_sg_elems);
+               }
        }
 }