forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c
....@@ -35,7 +35,6 @@
3535 */
3636
3737 #define DRV_NAME "libcxgb"
38
-#define DRV_VERSION "1.0.0-ko"
3938 #define pr_fmt(fmt) DRV_NAME ": " fmt
4039
4140 #include <linux/kernel.h>
....@@ -123,6 +122,9 @@
123122 unsigned int cpu;
124123 int i;
125124
125
+ if (!ppm->pool)
126
+ return -EINVAL;
127
+
126128 cpu = get_cpu();
127129 pool = per_cpu_ptr(ppm->pool, cpu);
128130 spin_lock_bh(&pool->lock);
....@@ -169,7 +171,9 @@
169171 }
170172
171173 ppm->next = i + count;
172
- if (ppm->next >= ppm->bmap_index_max)
174
+ if (ppm->max_index_in_edram && (ppm->next >= ppm->max_index_in_edram))
175
+ ppm->next = 0;
176
+ else if (ppm->next >= ppm->bmap_index_max)
173177 ppm->next = 0;
174178
175179 spin_unlock_bh(&ppm->map_lock);
....@@ -382,18 +386,36 @@
382386
383387 int cxgbi_ppm_init(void **ppm_pp, struct net_device *ndev,
384388 struct pci_dev *pdev, void *lldev,
385
- struct cxgbi_tag_format *tformat,
386
- unsigned int ppmax,
387
- unsigned int llimit,
388
- unsigned int start,
389
- unsigned int reserve_factor)
389
+ struct cxgbi_tag_format *tformat, unsigned int iscsi_size,
390
+ unsigned int llimit, unsigned int start,
391
+ unsigned int reserve_factor, unsigned int iscsi_edram_start,
392
+ unsigned int iscsi_edram_size)
390393 {
391394 struct cxgbi_ppm *ppm = (struct cxgbi_ppm *)(*ppm_pp);
392395 struct cxgbi_ppm_pool *pool = NULL;
393
- unsigned int ppmax_pool = 0;
394396 unsigned int pool_index_max = 0;
395
- unsigned int alloc_sz;
397
+ unsigned int ppmax_pool = 0;
396398 unsigned int ppod_bmap_size;
399
+ unsigned int alloc_sz;
400
+ unsigned int ppmax;
401
+
402
+ if (!iscsi_edram_start)
403
+ iscsi_edram_size = 0;
404
+
405
+ if (iscsi_edram_size &&
406
+ ((iscsi_edram_start + iscsi_edram_size) != start)) {
407
+ pr_err("iscsi ppod region not contiguous: EDRAM start 0x%x "
408
+ "size 0x%x DDR start 0x%x\n",
409
+ iscsi_edram_start, iscsi_edram_size, start);
410
+ return -EINVAL;
411
+ }
412
+
413
+ if (iscsi_edram_size) {
414
+ reserve_factor = 0;
415
+ start = iscsi_edram_start;
416
+ }
417
+
418
+ ppmax = (iscsi_edram_size + iscsi_size) >> PPOD_SIZE_SHIFT;
397419
398420 if (ppm) {
399421 pr_info("ippm: %s, ppm 0x%p,0x%p already initialized, %u/%u.\n",
....@@ -433,6 +455,14 @@
433455 pr_info("%s: %u - %u < %u * 8, mask extra bits %u, %u.\n",
434456 __func__, ppmax, ppmax_pool, ppod_bmap_size, start,
435457 end);
458
+ }
459
+ if (iscsi_edram_size) {
460
+ unsigned int first_ddr_idx =
461
+ iscsi_edram_size >> PPOD_SIZE_SHIFT;
462
+
463
+ ppm->max_index_in_edram = first_ddr_idx - 1;
464
+ bitmap_set(ppm->ppod_bmap, first_ddr_idx, 1);
465
+ pr_debug("reserved %u ppod in bitmap\n", first_ddr_idx);
436466 }
437467
438468 spin_lock_init(&ppm->map_lock);
....@@ -499,5 +529,4 @@
499529
500530 MODULE_AUTHOR("Chelsio Communications");
501531 MODULE_DESCRIPTION("Chelsio common library");
502
-MODULE_VERSION(DRV_VERSION);
503532 MODULE_LICENSE("Dual BSD/GPL");