@@ -48,28 +48,27 @@ netxen_poll_rsp(struct netxen_adapter *adapter)
4848}
4949
5050static u32
51- netxen_issue_cmd (struct netxen_adapter * adapter ,
52- u32 pci_fn , u32 version , u32 arg1 , u32 arg2 , u32 arg3 , u32 cmd )
51+ netxen_issue_cmd (struct netxen_adapter * adapter , struct netxen_cmd_args * cmd )
5352{
5453 u32 rsp ;
5554 u32 signature = 0 ;
5655 u32 rcode = NX_RCODE_SUCCESS ;
5756
58- signature = NX_CDRP_SIGNATURE_MAKE (pci_fn , version );
59-
57+ signature = NX_CDRP_SIGNATURE_MAKE (adapter -> ahw . pci_func ,
58+ NXHAL_VERSION );
6059 /* Acquire semaphore before accessing CRB */
6160 if (netxen_api_lock (adapter ))
6261 return NX_RCODE_TIMEOUT ;
6362
6463 NXWR32 (adapter , NX_SIGN_CRB_OFFSET , signature );
6564
66- NXWR32 (adapter , NX_ARG1_CRB_OFFSET , arg1 );
65+ NXWR32 (adapter , NX_ARG1_CRB_OFFSET , cmd -> req . arg1 );
6766
68- NXWR32 (adapter , NX_ARG2_CRB_OFFSET , arg2 );
67+ NXWR32 (adapter , NX_ARG2_CRB_OFFSET , cmd -> req . arg2 );
6968
70- NXWR32 (adapter , NX_ARG3_CRB_OFFSET , arg3 );
69+ NXWR32 (adapter , NX_ARG3_CRB_OFFSET , cmd -> req . arg3 );
7170
72- NXWR32 (adapter , NX_CDRP_CRB_OFFSET , NX_CDRP_FORM_CMD (cmd ));
71+ NXWR32 (adapter , NX_CDRP_CRB_OFFSET , NX_CDRP_FORM_CMD (cmd -> req . cmd ));
7372
7473 rsp = netxen_poll_rsp (adapter );
7574
@@ -83,8 +82,15 @@ netxen_issue_cmd(struct netxen_adapter *adapter,
8382
8483 printk (KERN_ERR "%s: failed card response code:0x%x\n" ,
8584 netxen_nic_driver_name , rcode );
85+ } else if (rsp == NX_CDRP_RSP_OK ) {
86+ if (cmd -> rsp .arg2 )
87+ cmd -> rsp .arg2 = NXRD32 (adapter , NX_ARG2_CRB_OFFSET );
88+ if (cmd -> rsp .arg3 )
89+ cmd -> rsp .arg3 = NXRD32 (adapter , NX_ARG3_CRB_OFFSET );
8690 }
8791
92+ if (cmd -> rsp .arg1 )
93+ cmd -> rsp .arg1 = NXRD32 (adapter , NX_ARG1_CRB_OFFSET );
8894 /* Release semaphore */
8995 netxen_api_unlock (adapter );
9096
@@ -96,15 +102,16 @@ nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, int mtu)
96102{
97103 u32 rcode = NX_RCODE_SUCCESS ;
98104 struct netxen_recv_context * recv_ctx = & adapter -> recv_ctx ;
105+ struct netxen_cmd_args cmd ;
106+
107+ memset (& cmd , 0 , sizeof (cmd ));
108+ cmd .req .cmd = NX_CDRP_CMD_SET_MTU ;
109+ cmd .req .arg1 = recv_ctx -> context_id ;
110+ cmd .req .arg2 = mtu ;
111+ cmd .req .arg3 = 0 ;
99112
100113 if (recv_ctx -> state == NX_HOST_CTX_STATE_ACTIVE )
101- rcode = netxen_issue_cmd (adapter ,
102- adapter -> ahw .pci_func ,
103- NXHAL_VERSION ,
104- recv_ctx -> context_id ,
105- mtu ,
106- 0 ,
107- NX_CDRP_CMD_SET_MTU );
114+ netxen_issue_cmd (adapter , & cmd );
108115
109116 if (rcode != NX_RCODE_SUCCESS )
110117 return - EIO ;
@@ -116,15 +123,14 @@ int
116123nx_fw_cmd_set_gbe_port (struct netxen_adapter * adapter ,
117124 u32 speed , u32 duplex , u32 autoneg )
118125{
119-
120- return netxen_issue_cmd (adapter ,
121- adapter -> ahw .pci_func ,
122- NXHAL_VERSION ,
123- speed ,
124- duplex ,
125- autoneg ,
126- NX_CDRP_CMD_CONFIG_GBE_PORT );
127-
126+ struct netxen_cmd_args cmd ;
127+
128+ memset (& cmd , 0 , sizeof (cmd ));
129+ cmd .req .cmd = NX_CDRP_CMD_CONFIG_GBE_PORT ;
130+ cmd .req .arg1 = speed ;
131+ cmd .req .arg2 = duplex ;
132+ cmd .req .arg3 = autoneg ;
133+ return netxen_issue_cmd (adapter , & cmd );
128134}
129135
130136static int
@@ -139,6 +145,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
139145 nx_cardrsp_sds_ring_t * prsp_sds ;
140146 struct nx_host_rds_ring * rds_ring ;
141147 struct nx_host_sds_ring * sds_ring ;
148+ struct netxen_cmd_args cmd ;
142149
143150 dma_addr_t hostrq_phys_addr , cardrsp_phys_addr ;
144151 u64 phys_addr ;
@@ -218,13 +225,12 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
218225 }
219226
220227 phys_addr = hostrq_phys_addr ;
221- err = netxen_issue_cmd (adapter ,
222- adapter -> ahw .pci_func ,
223- NXHAL_VERSION ,
224- (u32 )(phys_addr >> 32 ),
225- (u32 )(phys_addr & 0xffffffff ),
226- rq_size ,
227- NX_CDRP_CMD_CREATE_RX_CTX );
228+ memset (& cmd , 0 , sizeof (cmd ));
229+ cmd .req .arg1 = (u32 )(phys_addr >> 32 );
230+ cmd .req .arg2 = (u32 )(phys_addr & 0xffffffff );
231+ cmd .req .arg3 = rq_size ;
232+ cmd .req .cmd = NX_CDRP_CMD_CREATE_RX_CTX ;
233+ err = netxen_issue_cmd (adapter , & cmd );
228234 if (err ) {
229235 printk (KERN_WARNING
230236 "Failed to create rx ctx in firmware%d\n" , err );
@@ -273,15 +279,15 @@ static void
273279nx_fw_cmd_destroy_rx_ctx (struct netxen_adapter * adapter )
274280{
275281 struct netxen_recv_context * recv_ctx = & adapter -> recv_ctx ;
282+ struct netxen_cmd_args cmd ;
276283
277- if (netxen_issue_cmd (adapter ,
278- adapter -> ahw .pci_func ,
279- NXHAL_VERSION ,
280- recv_ctx -> context_id ,
281- NX_DESTROY_CTX_RESET ,
282- 0 ,
283- NX_CDRP_CMD_DESTROY_RX_CTX )) {
284+ memset (& cmd , 0 , sizeof (cmd ));
285+ cmd .req .arg1 = recv_ctx -> context_id ;
286+ cmd .req .arg2 = NX_DESTROY_CTX_RESET ;
287+ cmd .req .arg3 = 0 ;
288+ cmd .req .cmd = NX_CDRP_CMD_DESTROY_RX_CTX ;
284289
290+ if (netxen_issue_cmd (adapter , & cmd )) {
285291 printk (KERN_WARNING
286292 "%s: Failed to destroy rx ctx in firmware\n" ,
287293 netxen_nic_driver_name );
@@ -302,6 +308,7 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter)
302308 dma_addr_t rq_phys_addr , rsp_phys_addr ;
303309 struct nx_host_tx_ring * tx_ring = adapter -> tx_ring ;
304310 struct netxen_recv_context * recv_ctx = & adapter -> recv_ctx ;
311+ struct netxen_cmd_args cmd ;
305312
306313 rq_size = SIZEOF_HOSTRQ_TX (nx_hostrq_tx_ctx_t );
307314 rq_addr = pci_alloc_consistent (adapter -> pdev ,
@@ -345,13 +352,12 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter)
345352 prq_cds -> ring_size = cpu_to_le32 (tx_ring -> num_desc );
346353
347354 phys_addr = rq_phys_addr ;
348- err = netxen_issue_cmd (adapter ,
349- adapter -> ahw .pci_func ,
350- NXHAL_VERSION ,
351- (u32 )(phys_addr >> 32 ),
352- ((u32 )phys_addr & 0xffffffff ),
353- rq_size ,
354- NX_CDRP_CMD_CREATE_TX_CTX );
355+ memset (& cmd , 0 , sizeof (cmd ));
356+ cmd .req .arg1 = (u32 )(phys_addr >> 32 );
357+ cmd .req .arg2 = ((u32 )phys_addr & 0xffffffff );
358+ cmd .req .arg3 = rq_size ;
359+ cmd .req .cmd = NX_CDRP_CMD_CREATE_TX_CTX ;
360+ err = netxen_issue_cmd (adapter , & cmd );
355361
356362 if (err == NX_RCODE_SUCCESS ) {
357363 temp = le32_to_cpu (prsp -> cds_ring .host_producer_crb );
@@ -380,14 +386,14 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter)
380386static void
381387nx_fw_cmd_destroy_tx_ctx (struct netxen_adapter * adapter )
382388{
383- if ( netxen_issue_cmd ( adapter ,
384- adapter -> ahw . pci_func ,
385- NXHAL_VERSION ,
386- adapter -> tx_context_id ,
387- NX_DESTROY_CTX_RESET ,
388- 0 ,
389- NX_CDRP_CMD_DESTROY_TX_CTX )) {
390-
389+ struct netxen_cmd_args cmd ;
390+
391+ memset ( & cmd , 0 , sizeof ( cmd ));
392+ cmd . req . arg1 = adapter -> tx_context_id ;
393+ cmd . req . arg2 = NX_DESTROY_CTX_RESET ;
394+ cmd . req . arg3 = 0 ;
395+ cmd . req . cmd = NX_CDRP_CMD_DESTROY_TX_CTX ;
396+ if ( netxen_issue_cmd ( adapter , & cmd )) {
391397 printk (KERN_WARNING
392398 "%s: Failed to destroy tx ctx in firmware\n" ,
393399 netxen_nic_driver_name );
@@ -398,34 +404,33 @@ int
398404nx_fw_cmd_query_phy (struct netxen_adapter * adapter , u32 reg , u32 * val )
399405{
400406 u32 rcode ;
401-
402- rcode = netxen_issue_cmd ( adapter ,
403- adapter -> ahw . pci_func ,
404- NXHAL_VERSION ,
405- reg ,
406- 0 ,
407- 0 ,
408- NX_CDRP_CMD_READ_PHY ) ;
409-
407+ struct netxen_cmd_args cmd ;
408+
409+ memset ( & cmd , 0 , sizeof ( cmd ));
410+ cmd . req . arg1 = reg ;
411+ cmd . req . arg2 = 0 ;
412+ cmd . req . arg3 = 0 ;
413+ cmd . req . cmd = NX_CDRP_CMD_READ_PHY ;
414+ cmd . rsp . arg1 = 1 ;
415+ rcode = netxen_issue_cmd ( adapter , & cmd );
410416 if (rcode != NX_RCODE_SUCCESS )
411417 return - EIO ;
412418
413- return NXRD32 ( adapter , NX_ARG1_CRB_OFFSET ) ;
419+ return cmd . rsp . arg1 ;
414420}
415421
416422int
417423nx_fw_cmd_set_phy (struct netxen_adapter * adapter , u32 reg , u32 val )
418424{
419425 u32 rcode ;
420-
421- rcode = netxen_issue_cmd (adapter ,
422- adapter -> ahw .pci_func ,
423- NXHAL_VERSION ,
424- reg ,
425- val ,
426- 0 ,
427- NX_CDRP_CMD_WRITE_PHY );
428-
426+ struct netxen_cmd_args cmd ;
427+
428+ memset (& cmd , 0 , sizeof (cmd ));
429+ cmd .req .arg1 = reg ;
430+ cmd .req .arg2 = val ;
431+ cmd .req .arg3 = 0 ;
432+ cmd .req .cmd = NX_CDRP_CMD_WRITE_PHY ;
433+ rcode = netxen_issue_cmd (adapter , & cmd );
429434 if (rcode != NX_RCODE_SUCCESS )
430435 return - EIO ;
431436
0 commit comments