7
7
#include <linux/module.h>
8
8
#include <linux/highmem.h>
9
9
#include <linux/folio_queue.h>
10
+ #include "../common/smbdirect/smbdirect_pdu.h"
10
11
#include "smbdirect.h"
11
12
#include "cifs_debug.h"
12
13
#include "cifsproto.h"
@@ -50,9 +51,6 @@ struct smb_extract_to_rdma {
50
51
static ssize_t smb_extract_iter_to_rdma (struct iov_iter * iter , size_t len ,
51
52
struct smb_extract_to_rdma * rdma );
52
53
53
- /* SMBD version number */
54
- #define SMBD_V1 0x0100
55
-
56
54
/* Port numbers for SMBD transport */
57
55
#define SMB_PORT 445
58
56
#define SMBD_PORT 5445
@@ -299,7 +297,7 @@ static void send_done(struct ib_cq *cq, struct ib_wc *wc)
299
297
mempool_free (request , request -> info -> request_mempool );
300
298
}
301
299
302
- static void dump_smbd_negotiate_resp (struct smbd_negotiate_resp * resp )
300
+ static void dump_smbdirect_negotiate_resp (struct smbdirect_negotiate_resp * resp )
303
301
{
304
302
log_rdma_event (INFO , "resp message min_version %u max_version %u negotiated_version %u credits_requested %u credits_granted %u status %u max_readwrite_size %u preferred_send_size %u max_receive_size %u max_fragmented_size %u\n" ,
305
303
resp -> min_version , resp -> max_version ,
@@ -318,15 +316,15 @@ static bool process_negotiation_response(
318
316
struct smbd_response * response , int packet_length )
319
317
{
320
318
struct smbd_connection * info = response -> info ;
321
- struct smbd_negotiate_resp * packet = smbd_response_payload (response );
319
+ struct smbdirect_negotiate_resp * packet = smbd_response_payload (response );
322
320
323
- if (packet_length < sizeof (struct smbd_negotiate_resp )) {
321
+ if (packet_length < sizeof (struct smbdirect_negotiate_resp )) {
324
322
log_rdma_event (ERR ,
325
323
"error: packet_length=%d\n" , packet_length );
326
324
return false;
327
325
}
328
326
329
- if (le16_to_cpu (packet -> negotiated_version ) != SMBD_V1 ) {
327
+ if (le16_to_cpu (packet -> negotiated_version ) != SMBDIRECT_V1 ) {
330
328
log_rdma_event (ERR , "error: negotiated_version=%x\n" ,
331
329
le16_to_cpu (packet -> negotiated_version ));
332
330
return false;
@@ -448,7 +446,7 @@ static void smbd_post_send_credits(struct work_struct *work)
448
446
/* Called from softirq, when recv is done */
449
447
static void recv_done (struct ib_cq * cq , struct ib_wc * wc )
450
448
{
451
- struct smbd_data_transfer * data_transfer ;
449
+ struct smbdirect_data_transfer * data_transfer ;
452
450
struct smbd_response * response =
453
451
container_of (wc -> wr_cqe , struct smbd_response , cqe );
454
452
struct smbd_connection * info = response -> info ;
@@ -474,7 +472,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
474
472
switch (response -> type ) {
475
473
/* SMBD negotiation response */
476
474
case SMBD_NEGOTIATE_RESP :
477
- dump_smbd_negotiate_resp (smbd_response_payload (response ));
475
+ dump_smbdirect_negotiate_resp (smbd_response_payload (response ));
478
476
info -> full_packet_received = true;
479
477
info -> negotiate_done =
480
478
process_negotiation_response (response , wc -> byte_len );
@@ -531,7 +529,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
531
529
/* Send a KEEP_ALIVE response right away if requested */
532
530
info -> keep_alive_requested = KEEP_ALIVE_NONE ;
533
531
if (le16_to_cpu (data_transfer -> flags ) &
534
- SMB_DIRECT_RESPONSE_REQUESTED ) {
532
+ SMBDIRECT_FLAG_RESPONSE_REQUESTED ) {
535
533
info -> keep_alive_requested = KEEP_ALIVE_PENDING ;
536
534
}
537
535
@@ -686,7 +684,7 @@ static int smbd_post_send_negotiate_req(struct smbd_connection *info)
686
684
struct ib_send_wr send_wr ;
687
685
int rc = - ENOMEM ;
688
686
struct smbd_request * request ;
689
- struct smbd_negotiate_req * packet ;
687
+ struct smbdirect_negotiate_req * packet ;
690
688
691
689
request = mempool_alloc (info -> request_mempool , GFP_KERNEL );
692
690
if (!request )
@@ -695,8 +693,8 @@ static int smbd_post_send_negotiate_req(struct smbd_connection *info)
695
693
request -> info = info ;
696
694
697
695
packet = smbd_request_payload (request );
698
- packet -> min_version = cpu_to_le16 (SMBD_V1 );
699
- packet -> max_version = cpu_to_le16 (SMBD_V1 );
696
+ packet -> min_version = cpu_to_le16 (SMBDIRECT_V1 );
697
+ packet -> max_version = cpu_to_le16 (SMBDIRECT_V1 );
700
698
packet -> reserved = 0 ;
701
699
packet -> credits_requested = cpu_to_le16 (info -> send_credit_target );
702
700
packet -> preferred_send_size = cpu_to_le32 (info -> max_send_size );
@@ -774,10 +772,10 @@ static int manage_credits_prior_sending(struct smbd_connection *info)
774
772
/*
775
773
* Check if we need to send a KEEP_ALIVE message
776
774
* The idle connection timer triggers a KEEP_ALIVE message when expires
777
- * SMB_DIRECT_RESPONSE_REQUESTED is set in the message flag to have peer send
775
+ * SMBDIRECT_FLAG_RESPONSE_REQUESTED is set in the message flag to have peer send
778
776
* back a response.
779
777
* return value:
780
- * 1 if SMB_DIRECT_RESPONSE_REQUESTED needs to be set
778
+ * 1 if SMBDIRECT_FLAG_RESPONSE_REQUESTED needs to be set
781
779
* 0: otherwise
782
780
*/
783
781
static int manage_keep_alive_before_sending (struct smbd_connection * info )
@@ -837,7 +835,7 @@ static int smbd_post_send_iter(struct smbd_connection *info,
837
835
int header_length ;
838
836
int data_length ;
839
837
struct smbd_request * request ;
840
- struct smbd_data_transfer * packet ;
838
+ struct smbdirect_data_transfer * packet ;
841
839
int new_credits = 0 ;
842
840
843
841
wait_credit :
@@ -919,7 +917,7 @@ static int smbd_post_send_iter(struct smbd_connection *info,
919
917
920
918
packet -> flags = 0 ;
921
919
if (manage_keep_alive_before_sending (info ))
922
- packet -> flags |= cpu_to_le16 (SMB_DIRECT_RESPONSE_REQUESTED );
920
+ packet -> flags |= cpu_to_le16 (SMBDIRECT_FLAG_RESPONSE_REQUESTED );
923
921
924
922
packet -> reserved = 0 ;
925
923
if (!data_length )
@@ -938,10 +936,10 @@ static int smbd_post_send_iter(struct smbd_connection *info,
938
936
le32_to_cpu (packet -> remaining_data_length ));
939
937
940
938
/* Map the packet to DMA */
941
- header_length = sizeof (struct smbd_data_transfer );
939
+ header_length = sizeof (struct smbdirect_data_transfer );
942
940
/* If this is a packet without payload, don't send padding */
943
941
if (!data_length )
944
- header_length = offsetof(struct smbd_data_transfer , padding );
942
+ header_length = offsetof(struct smbdirect_data_transfer , padding );
945
943
946
944
request -> sge [0 ].addr = ib_dma_map_single (info -> id -> device ,
947
945
(void * )packet ,
@@ -1432,7 +1430,7 @@ static int allocate_caches_and_workqueue(struct smbd_connection *info)
1432
1430
kmem_cache_create (
1433
1431
name ,
1434
1432
sizeof (struct smbd_request ) +
1435
- sizeof (struct smbd_data_transfer ),
1433
+ sizeof (struct smbdirect_data_transfer ),
1436
1434
0 , SLAB_HWCACHE_ALIGN , NULL );
1437
1435
if (!info -> request_cache )
1438
1436
return - ENOMEM ;
@@ -1735,7 +1733,7 @@ static int smbd_recv_buf(struct smbd_connection *info, char *buf,
1735
1733
unsigned int size )
1736
1734
{
1737
1735
struct smbd_response * response ;
1738
- struct smbd_data_transfer * data_transfer ;
1736
+ struct smbdirect_data_transfer * data_transfer ;
1739
1737
int to_copy , to_read , data_read , offset ;
1740
1738
u32 data_length , remaining_data_length , data_offset ;
1741
1739
int rc ;
0 commit comments