diff options
author | Dhananjay Phadke <dhananjay@netxen.com> | 2009-04-07 18:50:43 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-04-08 18:58:28 -0400 |
commit | 71dcddbdd35487eb931aa8aab28a2df474008754 (patch) | |
tree | 64b1b1aca84e118edea9865a350aed93e0a8b813 /drivers/net/netxen | |
parent | 3bf26ce3f4cc3c9e0d0478b4016c6113a16faaf1 (diff) |
netxen: allocate status rings dynamically
This reduces netxen_adapter footprint when rss (msi-x) is disabled.
Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/netxen')
-rw-r--r-- | drivers/net/netxen/netxen_nic.h | 10 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_main.c | 26 |
2 files changed, 30 insertions, 6 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index f4d7e2db700b..e0f329ff3691 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h | |||
@@ -762,7 +762,7 @@ struct netxen_recv_context { | |||
762 | u16 virt_port; | 762 | u16 virt_port; |
763 | 763 | ||
764 | struct nx_host_rds_ring rds_rings[NUM_RCV_DESC_RINGS]; | 764 | struct nx_host_rds_ring rds_rings[NUM_RCV_DESC_RINGS]; |
765 | struct nx_host_sds_ring sds_rings[NUM_STS_DESC_RINGS]; | 765 | struct nx_host_sds_ring *sds_rings; |
766 | }; | 766 | }; |
767 | 767 | ||
768 | /* New HW context creation */ | 768 | /* New HW context creation */ |
@@ -1203,10 +1203,10 @@ struct netxen_adapter { | |||
1203 | 1203 | ||
1204 | spinlock_t tx_clean_lock; | 1204 | spinlock_t tx_clean_lock; |
1205 | 1205 | ||
1206 | u32 num_txd; | 1206 | u16 num_txd; |
1207 | u32 num_rxd; | 1207 | u16 num_rxd; |
1208 | u32 num_jumbo_rxd; | 1208 | u16 num_jumbo_rxd; |
1209 | u32 num_lro_rxd; | 1209 | u16 num_lro_rxd; |
1210 | 1210 | ||
1211 | u8 max_rds_rings; | 1211 | u8 max_rds_rings; |
1212 | u8 max_sds_rings; | 1212 | u8 max_sds_rings; |
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index bd93296be4dd..cbd47ae694ba 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -153,7 +153,24 @@ static inline void netxen_nic_enable_int(struct nx_host_sds_ring *sds_ring) | |||
153 | adapter->legacy_intr.tgt_mask_reg, 0xfbff); | 153 | adapter->legacy_intr.tgt_mask_reg, 0xfbff); |
154 | } | 154 | } |
155 | 155 | ||
156 | static int | ||
157 | netxen_alloc_sds_rings(struct netxen_recv_context *recv_ctx, int count) | ||
158 | { | ||
159 | int size = sizeof(struct nx_host_sds_ring) * count; | ||
160 | |||
161 | recv_ctx->sds_rings = kzalloc(size, GFP_KERNEL); | ||
162 | |||
163 | return (recv_ctx->sds_rings == NULL); | ||
164 | } | ||
165 | |||
156 | static void | 166 | static void |
167 | netxen_free_sds_rings(struct netxen_recv_context *recv_ctx) | ||
168 | { | ||
169 | if (recv_ctx->sds_rings != NULL) | ||
170 | kfree(recv_ctx->sds_rings); | ||
171 | } | ||
172 | |||
173 | static int | ||
157 | netxen_napi_add(struct netxen_adapter *adapter, struct net_device *netdev) | 174 | netxen_napi_add(struct netxen_adapter *adapter, struct net_device *netdev) |
158 | { | 175 | { |
159 | int ring; | 176 | int ring; |
@@ -165,11 +182,16 @@ netxen_napi_add(struct netxen_adapter *adapter, struct net_device *netdev) | |||
165 | else | 182 | else |
166 | adapter->max_sds_rings = 1; | 183 | adapter->max_sds_rings = 1; |
167 | 184 | ||
185 | if (netxen_alloc_sds_rings(recv_ctx, adapter->max_sds_rings)) | ||
186 | return 1; | ||
187 | |||
168 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { | 188 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { |
169 | sds_ring = &recv_ctx->sds_rings[ring]; | 189 | sds_ring = &recv_ctx->sds_rings[ring]; |
170 | netif_napi_add(netdev, &sds_ring->napi, | 190 | netif_napi_add(netdev, &sds_ring->napi, |
171 | netxen_nic_poll, NETXEN_NETDEV_WEIGHT); | 191 | netxen_nic_poll, NETXEN_NETDEV_WEIGHT); |
172 | } | 192 | } |
193 | |||
194 | return 0; | ||
173 | } | 195 | } |
174 | 196 | ||
175 | static void | 197 | static void |
@@ -1028,7 +1050,8 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1028 | 1050 | ||
1029 | netdev->irq = adapter->msix_entries[0].vector; | 1051 | netdev->irq = adapter->msix_entries[0].vector; |
1030 | 1052 | ||
1031 | netxen_napi_add(adapter, netdev); | 1053 | if (netxen_napi_add(adapter, netdev)) |
1054 | goto err_out_disable_msi; | ||
1032 | 1055 | ||
1033 | init_timer(&adapter->watchdog_timer); | 1056 | init_timer(&adapter->watchdog_timer); |
1034 | adapter->watchdog_timer.function = &netxen_watchdog; | 1057 | adapter->watchdog_timer.function = &netxen_watchdog; |
@@ -1110,6 +1133,7 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) | |||
1110 | netxen_free_adapter_offload(adapter); | 1133 | netxen_free_adapter_offload(adapter); |
1111 | 1134 | ||
1112 | netxen_teardown_intr(adapter); | 1135 | netxen_teardown_intr(adapter); |
1136 | netxen_free_sds_rings(&adapter->recv_ctx); | ||
1113 | 1137 | ||
1114 | netxen_cleanup_pci_map(adapter); | 1138 | netxen_cleanup_pci_map(adapter); |
1115 | 1139 | ||