| .. | .. |
|---|
| 35 | 35 | */ |
|---|
| 36 | 36 | |
|---|
| 37 | 37 | #define DRV_NAME "libcxgb" |
|---|
| 38 | | -#define DRV_VERSION "1.0.0-ko" |
|---|
| 39 | 38 | #define pr_fmt(fmt) DRV_NAME ": " fmt |
|---|
| 40 | 39 | |
|---|
| 41 | 40 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 123 | 122 | unsigned int cpu; |
|---|
| 124 | 123 | int i; |
|---|
| 125 | 124 | |
|---|
| 125 | + if (!ppm->pool) |
|---|
| 126 | + return -EINVAL; |
|---|
| 127 | + |
|---|
| 126 | 128 | cpu = get_cpu(); |
|---|
| 127 | 129 | pool = per_cpu_ptr(ppm->pool, cpu); |
|---|
| 128 | 130 | spin_lock_bh(&pool->lock); |
|---|
| .. | .. |
|---|
| 169 | 171 | } |
|---|
| 170 | 172 | |
|---|
| 171 | 173 | 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) |
|---|
| 173 | 177 | ppm->next = 0; |
|---|
| 174 | 178 | |
|---|
| 175 | 179 | spin_unlock_bh(&ppm->map_lock); |
|---|
| .. | .. |
|---|
| 382 | 386 | |
|---|
| 383 | 387 | int cxgbi_ppm_init(void **ppm_pp, struct net_device *ndev, |
|---|
| 384 | 388 | 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) |
|---|
| 390 | 393 | { |
|---|
| 391 | 394 | struct cxgbi_ppm *ppm = (struct cxgbi_ppm *)(*ppm_pp); |
|---|
| 392 | 395 | struct cxgbi_ppm_pool *pool = NULL; |
|---|
| 393 | | - unsigned int ppmax_pool = 0; |
|---|
| 394 | 396 | unsigned int pool_index_max = 0; |
|---|
| 395 | | - unsigned int alloc_sz; |
|---|
| 397 | + unsigned int ppmax_pool = 0; |
|---|
| 396 | 398 | 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; |
|---|
| 397 | 419 | |
|---|
| 398 | 420 | if (ppm) { |
|---|
| 399 | 421 | pr_info("ippm: %s, ppm 0x%p,0x%p already initialized, %u/%u.\n", |
|---|
| .. | .. |
|---|
| 433 | 455 | pr_info("%s: %u - %u < %u * 8, mask extra bits %u, %u.\n", |
|---|
| 434 | 456 | __func__, ppmax, ppmax_pool, ppod_bmap_size, start, |
|---|
| 435 | 457 | 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); |
|---|
| 436 | 466 | } |
|---|
| 437 | 467 | |
|---|
| 438 | 468 | spin_lock_init(&ppm->map_lock); |
|---|
| .. | .. |
|---|
| 499 | 529 | |
|---|
| 500 | 530 | MODULE_AUTHOR("Chelsio Communications"); |
|---|
| 501 | 531 | MODULE_DESCRIPTION("Chelsio common library"); |
|---|
| 502 | | -MODULE_VERSION(DRV_VERSION); |
|---|
| 503 | 532 | MODULE_LICENSE("Dual BSD/GPL"); |
|---|