Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

smb: smbdirect: introduce smbdirect_socket.logging infrastructure

This will be used by client and server in order to keep controlling
the logging when we move to shared functions.

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Stefan Metzmacher and committed by
Steve French
c3182398 731a5302

+127
+127
fs/smb/common/smbdirect/smbdirect_socket.h
··· 350 350 u64 dequeue_reassembly_queue; 351 351 u64 send_empty; 352 352 } statistics; 353 + 354 + struct { 355 + #define SMBDIRECT_LOG_ERR 0x0 356 + #define SMBDIRECT_LOG_INFO 0x1 357 + 358 + #define SMBDIRECT_LOG_OUTGOING 0x1 359 + #define SMBDIRECT_LOG_INCOMING 0x2 360 + #define SMBDIRECT_LOG_READ 0x4 361 + #define SMBDIRECT_LOG_WRITE 0x8 362 + #define SMBDIRECT_LOG_RDMA_SEND 0x10 363 + #define SMBDIRECT_LOG_RDMA_RECV 0x20 364 + #define SMBDIRECT_LOG_KEEP_ALIVE 0x40 365 + #define SMBDIRECT_LOG_RDMA_EVENT 0x80 366 + #define SMBDIRECT_LOG_RDMA_MR 0x100 367 + #define SMBDIRECT_LOG_RDMA_RW 0x200 368 + #define SMBDIRECT_LOG_NEGOTIATE 0x400 369 + void *private_ptr; 370 + bool (*needed)(struct smbdirect_socket *sc, 371 + void *private_ptr, 372 + unsigned int lvl, 373 + unsigned int cls); 374 + void (*vaprintf)(struct smbdirect_socket *sc, 375 + const char *func, 376 + unsigned int line, 377 + void *private_ptr, 378 + unsigned int lvl, 379 + unsigned int cls, 380 + struct va_format *vaf); 381 + } logging; 353 382 }; 354 383 355 384 static void __smbdirect_socket_disabled_work(struct work_struct *work) ··· 388 359 */ 389 360 WARN_ON_ONCE(1); 390 361 } 362 + 363 + static bool __smbdirect_log_needed(struct smbdirect_socket *sc, 364 + void *private_ptr, 365 + unsigned int lvl, 366 + unsigned int cls) 367 + { 368 + /* 369 + * Should never be called, the caller should 370 + * set it's own functions. 371 + */ 372 + WARN_ON_ONCE(1); 373 + return false; 374 + } 375 + 376 + static void __smbdirect_log_vaprintf(struct smbdirect_socket *sc, 377 + const char *func, 378 + unsigned int line, 379 + void *private_ptr, 380 + unsigned int lvl, 381 + unsigned int cls, 382 + struct va_format *vaf) 383 + { 384 + /* 385 + * Should never be called, the caller should 386 + * set it's own functions. 387 + */ 388 + WARN_ON_ONCE(1); 389 + } 390 + 391 + __printf(6, 7) 392 + static void __smbdirect_log_printf(struct smbdirect_socket *sc, 393 + const char *func, 394 + unsigned int line, 395 + unsigned int lvl, 396 + unsigned int cls, 397 + const char *fmt, 398 + ...); 399 + __maybe_unused 400 + static void __smbdirect_log_printf(struct smbdirect_socket *sc, 401 + const char *func, 402 + unsigned int line, 403 + unsigned int lvl, 404 + unsigned int cls, 405 + const char *fmt, 406 + ...) 407 + { 408 + struct va_format vaf; 409 + va_list args; 410 + 411 + va_start(args, fmt); 412 + 413 + vaf.fmt = fmt; 414 + vaf.va = &args; 415 + 416 + sc->logging.vaprintf(sc, 417 + func, 418 + line, 419 + sc->logging.private_ptr, 420 + lvl, 421 + cls, 422 + &vaf); 423 + va_end(args); 424 + } 425 + 426 + #define ___smbdirect_log_generic(sc, func, line, lvl, cls, fmt, args...) do { \ 427 + if (sc->logging.needed(sc, sc->logging.private_ptr, lvl, cls)) { \ 428 + __smbdirect_log_printf(sc, func, line, lvl, cls, fmt, ##args); \ 429 + } \ 430 + } while (0) 431 + #define __smbdirect_log_generic(sc, lvl, cls, fmt, args...) \ 432 + ___smbdirect_log_generic(sc, __func__, __LINE__, lvl, cls, fmt, ##args) 433 + 434 + #define smbdirect_log_outgoing(sc, lvl, fmt, args...) \ 435 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_OUTGOING, fmt, ##args) 436 + #define smbdirect_log_incoming(sc, lvl, fmt, args...) \ 437 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_INCOMING, fmt, ##args) 438 + #define smbdirect_log_read(sc, lvl, fmt, args...) \ 439 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_READ, fmt, ##args) 440 + #define smbdirect_log_write(sc, lvl, fmt, args...) \ 441 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_WRITE, fmt, ##args) 442 + #define smbdirect_log_rdma_send(sc, lvl, fmt, args...) \ 443 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_RDMA_SEND, fmt, ##args) 444 + #define smbdirect_log_rdma_recv(sc, lvl, fmt, args...) \ 445 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_RDMA_RECV, fmt, ##args) 446 + #define smbdirect_log_keep_alive(sc, lvl, fmt, args...) \ 447 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_KEEP_ALIVE, fmt, ##args) 448 + #define smbdirect_log_rdma_event(sc, lvl, fmt, args...) \ 449 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_RDMA_EVENT, fmt, ##args) 450 + #define smbdirect_log_rdma_mr(sc, lvl, fmt, args...) \ 451 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_RDMA_MR, fmt, ##args) 452 + #define smbdirect_log_rdma_rw(sc, lvl, fmt, args...) \ 453 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_RDMA_RW, fmt, ##args) 454 + #define smbdirect_log_negotiate(sc, lvl, fmt, args...) \ 455 + __smbdirect_log_generic(sc, lvl, SMBDIRECT_LOG_NEGOTIATE, fmt, ##args) 391 456 392 457 static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc) 393 458 { ··· 543 420 INIT_WORK(&sc->mr_io.recovery_work, __smbdirect_socket_disabled_work); 544 421 disable_work_sync(&sc->mr_io.recovery_work); 545 422 init_waitqueue_head(&sc->mr_io.cleanup.wait_queue); 423 + 424 + sc->logging.private_ptr = NULL; 425 + sc->logging.needed = __smbdirect_log_needed; 426 + sc->logging.vaprintf = __smbdirect_log_vaprintf; 546 427 } 547 428 548 429 #define __SMBDIRECT_CHECK_STATUS_FAILED(__sc, __expected_status, __error_cmd, __unexpected_cmd) ({ \