77#include <linux/module.h>
88#include <linux/highmem.h>
99#include <linux/folio_queue.h>
10+ #include "../common/smbdirect/smbdirect_pdu.h"
1011#include "smbdirect.h"
1112#include "cifs_debug.h"
1213#include "cifsproto.h"
@@ -50,9 +51,6 @@ struct smb_extract_to_rdma {
5051static ssize_t smb_extract_iter_to_rdma (struct iov_iter * iter , size_t len ,
5152 struct smb_extract_to_rdma * rdma );
5253
53- /* SMBD version number */
54- #define SMBD_V1 0x0100
55-
5654/* Port numbers for SMBD transport */
5755#define SMB_PORT 445
5856#define SMBD_PORT 5445
@@ -299,7 +297,7 @@ static void send_done(struct ib_cq *cq, struct ib_wc *wc)
299297 mempool_free (request , request -> info -> request_mempool );
300298}
301299
302- static void dump_smbd_negotiate_resp (struct smbd_negotiate_resp * resp )
300+ static void dump_smbdirect_negotiate_resp (struct smbdirect_negotiate_resp * resp )
303301{
304302 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" ,
305303 resp -> min_version , resp -> max_version ,
@@ -318,15 +316,15 @@ static bool process_negotiation_response(
318316 struct smbd_response * response , int packet_length )
319317{
320318 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 );
322320
323- if (packet_length < sizeof (struct smbd_negotiate_resp )) {
321+ if (packet_length < sizeof (struct smbdirect_negotiate_resp )) {
324322 log_rdma_event (ERR ,
325323 "error: packet_length=%d\n" , packet_length );
326324 return false;
327325 }
328326
329- if (le16_to_cpu (packet -> negotiated_version ) != SMBD_V1 ) {
327+ if (le16_to_cpu (packet -> negotiated_version ) != SMBDIRECT_V1 ) {
330328 log_rdma_event (ERR , "error: negotiated_version=%x\n" ,
331329 le16_to_cpu (packet -> negotiated_version ));
332330 return false;
@@ -448,7 +446,7 @@ static void smbd_post_send_credits(struct work_struct *work)
448446/* Called from softirq, when recv is done */
449447static void recv_done (struct ib_cq * cq , struct ib_wc * wc )
450448{
451- struct smbd_data_transfer * data_transfer ;
449+ struct smbdirect_data_transfer * data_transfer ;
452450 struct smbd_response * response =
453451 container_of (wc -> wr_cqe , struct smbd_response , cqe );
454452 struct smbd_connection * info = response -> info ;
@@ -474,7 +472,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
474472 switch (response -> type ) {
475473 /* SMBD negotiation response */
476474 case SMBD_NEGOTIATE_RESP :
477- dump_smbd_negotiate_resp (smbd_response_payload (response ));
475+ dump_smbdirect_negotiate_resp (smbd_response_payload (response ));
478476 info -> full_packet_received = true;
479477 info -> negotiate_done =
480478 process_negotiation_response (response , wc -> byte_len );
@@ -531,7 +529,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
531529 /* Send a KEEP_ALIVE response right away if requested */
532530 info -> keep_alive_requested = KEEP_ALIVE_NONE ;
533531 if (le16_to_cpu (data_transfer -> flags ) &
534- SMB_DIRECT_RESPONSE_REQUESTED ) {
532+ SMBDIRECT_FLAG_RESPONSE_REQUESTED ) {
535533 info -> keep_alive_requested = KEEP_ALIVE_PENDING ;
536534 }
537535
@@ -686,7 +684,7 @@ static int smbd_post_send_negotiate_req(struct smbd_connection *info)
686684 struct ib_send_wr send_wr ;
687685 int rc = - ENOMEM ;
688686 struct smbd_request * request ;
689- struct smbd_negotiate_req * packet ;
687+ struct smbdirect_negotiate_req * packet ;
690688
691689 request = mempool_alloc (info -> request_mempool , GFP_KERNEL );
692690 if (!request )
@@ -695,8 +693,8 @@ static int smbd_post_send_negotiate_req(struct smbd_connection *info)
695693 request -> info = info ;
696694
697695 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 );
700698 packet -> reserved = 0 ;
701699 packet -> credits_requested = cpu_to_le16 (info -> send_credit_target );
702700 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)
774772/*
775773 * Check if we need to send a KEEP_ALIVE message
776774 * 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
778776 * back a response.
779777 * return value:
780- * 1 if SMB_DIRECT_RESPONSE_REQUESTED needs to be set
778+ * 1 if SMBDIRECT_FLAG_RESPONSE_REQUESTED needs to be set
781779 * 0: otherwise
782780 */
783781static int manage_keep_alive_before_sending (struct smbd_connection * info )
@@ -837,7 +835,7 @@ static int smbd_post_send_iter(struct smbd_connection *info,
837835 int header_length ;
838836 int data_length ;
839837 struct smbd_request * request ;
840- struct smbd_data_transfer * packet ;
838+ struct smbdirect_data_transfer * packet ;
841839 int new_credits = 0 ;
842840
843841wait_credit :
@@ -919,7 +917,7 @@ static int smbd_post_send_iter(struct smbd_connection *info,
919917
920918 packet -> flags = 0 ;
921919 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 );
923921
924922 packet -> reserved = 0 ;
925923 if (!data_length )
@@ -938,10 +936,10 @@ static int smbd_post_send_iter(struct smbd_connection *info,
938936 le32_to_cpu (packet -> remaining_data_length ));
939937
940938 /* Map the packet to DMA */
941- header_length = sizeof (struct smbd_data_transfer );
939+ header_length = sizeof (struct smbdirect_data_transfer );
942940 /* If this is a packet without payload, don't send padding */
943941 if (!data_length )
944- header_length = offsetof(struct smbd_data_transfer , padding );
942+ header_length = offsetof(struct smbdirect_data_transfer , padding );
945943
946944 request -> sge [0 ].addr = ib_dma_map_single (info -> id -> device ,
947945 (void * )packet ,
@@ -1432,7 +1430,7 @@ static int allocate_caches_and_workqueue(struct smbd_connection *info)
14321430 kmem_cache_create (
14331431 name ,
14341432 sizeof (struct smbd_request ) +
1435- sizeof (struct smbd_data_transfer ),
1433+ sizeof (struct smbdirect_data_transfer ),
14361434 0 , SLAB_HWCACHE_ALIGN , NULL );
14371435 if (!info -> request_cache )
14381436 return - ENOMEM ;
@@ -1735,7 +1733,7 @@ static int smbd_recv_buf(struct smbd_connection *info, char *buf,
17351733 unsigned int size )
17361734{
17371735 struct smbd_response * response ;
1738- struct smbd_data_transfer * data_transfer ;
1736+ struct smbdirect_data_transfer * data_transfer ;
17391737 int to_copy , to_read , data_read , offset ;
17401738 u32 data_length , remaining_data_length , data_offset ;
17411739 int rc ;
0 commit comments