Skip to content
Snippets Groups Projects
Commit 30761ebc authored by Laura Rientsma's avatar Laura Rientsma
Browse files

changed loop for finding pci devices to a while loop, pci_get_device returns...

changed loop for finding pci devices to a while loop, pci_get_device returns NULL when all devices are found (works, tested with 2 cards)
parent 47577594
No related branches found
No related tags found
1 merge request!1Removed vmk180_serial_demo ip core, and use versal_network_device ip instead,...
......@@ -46,6 +46,4 @@ struct flxnet_peer {
#define FLX_DEV_MAGIC 0xCECABABAUL
#define MAXCARDS 1 // max number of FLX cards in a server
#endif
#endif
\ No newline at end of file
......@@ -71,7 +71,6 @@ struct tx_queue {
struct tx_packet *packets;
};
struct tx_queue tx_queue; //[MAXCARDS]
static LIST_HEAD(peers);
......@@ -119,17 +118,17 @@ static inline bool check_flag(void* __iomem reg, int bit_id) {
static inline void set_flag(void* __iomem reg, int bit_id) {
uint32_t temp_reg = register_read(reg);
temp_reg |= (1 << bit_id);
pr_info("flxnet_dev: temp_reg is %u", temp_reg);
//pr_info("flxnet_dev: temp_reg is %u", temp_reg);
register_write(reg, temp_reg);
pr_info("flxnet_dev: flag set");
//pr_info("flxnet_dev: flag set");
}
static inline void clear_flag(void* __iomem reg, int bit_id) {
uint32_t temp_reg = register_read(reg);
temp_reg &= ~(1 << bit_id);
pr_info("flxnet_dev: temp_reg is %u", temp_reg);
//pr_info("flxnet_dev: temp_reg is %u", temp_reg);
register_write(reg, temp_reg);
pr_info("flxnet_dev: flag cleared");
//pr_info("flxnet_dev: flag cleared");
}
/* static inline void print_status_reg(struct flxnet_peer *peer) {
......@@ -141,7 +140,7 @@ static inline void clear_flag(void* __iomem reg, int bit_id) {
(temp_reg & (1<<HAS_ROOM_FOR_WORD) >0),
(temp_reg & (1<<BLOCK_AVAILABLE) >0),
(temp_reg & (1<<WORD_AVAILABLE) >0)
)
);
} */
static inline bool is_word_available(struct flxnet_peer *peer) {
......@@ -178,7 +177,9 @@ static inline t_fifo_word recv_word(struct flxnet_peer* peer) {
static inline void send_eop(struct flxnet_peer *peer) {
set_flag(peer->regs + peer->reg_status, SEND_IS_EOP);
send_word(peer, FLXNET_EOP);
pr_info("flxnet_dev: end of packet sent");
if (message_level & NETIF_MSG_TX_DONE) {
pr_info("flxnet_dev: end of packet sent");
}
clear_flag(peer->regs + peer->reg_status, SEND_IS_EOP);
}
......@@ -994,7 +995,7 @@ int register_network(int index) {
goto err_alloc_etherdev;
}
strlcpy(flxnet->name, "flxnet%d", index);
strlcpy(flxnet->name, "flxnet%d", IFNAMSIZ);
flxnet->netdev_ops = &flx_netdev_ops;
flxnet->ethtool_ops = &ethtool_ops;
flxnet->watchdog_timeo = msecs_to_jiffies(TX_TIMEOUT_MS);
......
......@@ -65,20 +65,33 @@ static int flxnet_pcie_init(void) {
int i;
int index = 0;
int rv = -ENODEV;
struct pci_dev *pdev; //previous device
pdev = NULL;
struct pci_dev *pdev; // previous device
pdev = NULL; // a new search for PCI devices is initiated by passing NULL as the pdev argument
pr_info("flxnet_pcie: loading %s module", DRV_MODULE_NAME);
for(i=0; i<MAXCARDS; i++) {
if ( (pdev = pci_get_device(0x10dc, 0x0427, pdev)) ) {
pr_info("flxnet_pcie: found %s", pci_name(pdev));
rv = configure_pcie_device(pdev, index);
index++;
if (rv < 0) {
pr_warn("flxnet_pcie: failed to configure %s", pci_name(pdev));
}
// if a PCI device is found, a pointer to its device structure is returned
pdev = pci_get_device(0x10dc, 0x0427, pdev);
// pdev returns NULL when all the PCI devices are found and stops searching
while (pdev != NULL) {
pr_info("flxnet_pcie: found %s", pci_name(pdev));
//pdev = pci_dev_get(pdev);
rv = configure_pcie_device(pdev, index);
if (rv < 0) {
pr_warn("flxnet_pcie: failed to configure %s", pci_name(pdev));
}
pr_info("flxnet_pcie: pci device %s with index %d", pci_name(pdev), index);
pdev = pci_get_device(0x10dc, 0x0427, pdev);
index++;
if (pdev == NULL) {
pr_info("flxnet_pcie: no more pcie devices found");
}
}
//pci_dev_put(pdev);
return rv;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment