|
2 | 2 | /* Copyright (C) 2024 Marvell. */ |
3 | 3 |
|
4 | 4 | #include <linux/iopoll.h> |
| 5 | +#include <linux/build_bug.h> |
5 | 6 |
|
6 | 7 | #include "octep_vdpa.h" |
7 | 8 |
|
@@ -358,7 +359,14 @@ u16 octep_get_vq_size(struct octep_hw *oct_hw) |
358 | 359 |
|
359 | 360 | static u32 octep_get_config_size(struct octep_hw *oct_hw) |
360 | 361 | { |
361 | | - return sizeof(struct virtio_net_config); |
| 362 | + switch (oct_hw->dev_id) { |
| 363 | + case VIRTIO_ID_NET: |
| 364 | + return sizeof(struct virtio_net_config); |
| 365 | + case VIRTIO_ID_CRYPTO: |
| 366 | + return sizeof(struct virtio_crypto_config); |
| 367 | + default: |
| 368 | + return 0; |
| 369 | + } |
362 | 370 | } |
363 | 371 |
|
364 | 372 | static void __iomem *octep_get_cap_addr(struct octep_hw *oct_hw, struct virtio_pci_cap *cap) |
@@ -416,8 +424,25 @@ static int octep_pci_signature_verify(struct octep_hw *oct_hw) |
416 | 424 | return 0; |
417 | 425 | } |
418 | 426 |
|
| 427 | +static void octep_vndr_data_process(struct octep_hw *oct_hw, |
| 428 | + struct octep_pci_vndr_data *vndr_data) |
| 429 | +{ |
| 430 | + BUILD_BUG_ON(sizeof(struct octep_pci_vndr_data) % 4 != 0); |
| 431 | + |
| 432 | + switch (vndr_data->id) { |
| 433 | + case OCTEP_PCI_VNDR_CFG_TYPE_VIRTIO_ID: |
| 434 | + oct_hw->dev_id = (u8)vndr_data->data; |
| 435 | + break; |
| 436 | + default: |
| 437 | + dev_err(&oct_hw->pdev->dev, "Invalid vendor data id %u\n", |
| 438 | + vndr_data->id); |
| 439 | + break; |
| 440 | + } |
| 441 | +} |
| 442 | + |
419 | 443 | int octep_hw_caps_read(struct octep_hw *oct_hw, struct pci_dev *pdev) |
420 | 444 | { |
| 445 | + struct octep_pci_vndr_data vndr_data; |
421 | 446 | struct octep_mbox __iomem *mbox; |
422 | 447 | struct device *dev = &pdev->dev; |
423 | 448 | struct virtio_pci_cap cap; |
@@ -466,6 +491,15 @@ int octep_hw_caps_read(struct octep_hw *oct_hw, struct pci_dev *pdev) |
466 | 491 | case VIRTIO_PCI_CAP_ISR_CFG: |
467 | 492 | oct_hw->isr = octep_get_cap_addr(oct_hw, &cap); |
468 | 493 | break; |
| 494 | + case VIRTIO_PCI_CAP_VENDOR_CFG: |
| 495 | + octep_pci_caps_read(oct_hw, &vndr_data, sizeof(vndr_data), pos); |
| 496 | + if (vndr_data.hdr.vendor_id != PCI_VENDOR_ID_CAVIUM) { |
| 497 | + dev_err(dev, "Invalid vendor data\n"); |
| 498 | + return -EINVAL; |
| 499 | + } |
| 500 | + |
| 501 | + octep_vndr_data_process(oct_hw, &vndr_data); |
| 502 | + break; |
469 | 503 | } |
470 | 504 |
|
471 | 505 | pos = cap.cap_next; |
@@ -495,8 +529,6 @@ int octep_hw_caps_read(struct octep_hw *oct_hw, struct pci_dev *pdev) |
495 | 529 | if (!oct_hw->vqs) |
496 | 530 | return -ENOMEM; |
497 | 531 |
|
498 | | - oct_hw->irq = -1; |
499 | | - |
500 | 532 | dev_info(&pdev->dev, "Device features : %llx\n", oct_hw->features); |
501 | 533 | dev_info(&pdev->dev, "Maximum queues : %u\n", oct_hw->nr_vring); |
502 | 534 |
|
|
0 commit comments