LCOV - code coverage report
Current view: top level - lib/nvmf - nvmf_internal.h (source / functions) Hit Total Coverage
Test: ut_cov_unit.info Lines: 24 24 100.0 %
Date: 2024-07-10 19:10:30 Functions: 13 17 76.5 %

          Line data    Source code
       1             : /*   SPDX-License-Identifier: BSD-3-Clause
       2             :  *   Copyright (C) 2016 Intel Corporation. All rights reserved.
       3             :  *   Copyright (c) 2019 Mellanox Technologies LTD. All rights reserved.
       4             :  *   Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
       5             :  */
       6             : 
       7             : #ifndef __NVMF_INTERNAL_H__
       8             : #define __NVMF_INTERNAL_H__
       9             : 
      10             : #include "spdk/stdinc.h"
      11             : 
      12             : #include "spdk/keyring.h"
      13             : #include "spdk/likely.h"
      14             : #include "spdk/nvmf.h"
      15             : #include "spdk/nvmf_cmd.h"
      16             : #include "spdk/nvmf_transport.h"
      17             : #include "spdk/nvmf_spec.h"
      18             : #include "spdk/assert.h"
      19             : #include "spdk/bdev.h"
      20             : #include "spdk/queue.h"
      21             : #include "spdk/util.h"
      22             : #include "spdk/thread.h"
      23             : #include "spdk/tree.h"
      24             : #include "spdk/bit_array.h"
      25             : 
      26             : /* The spec reserves cntlid values in the range FFF0h to FFFFh. */
      27             : #define NVMF_MIN_CNTLID 1
      28             : #define NVMF_MAX_CNTLID 0xFFEF
      29             : 
      30             : enum spdk_nvmf_tgt_state {
      31             :         NVMF_TGT_IDLE = 0,
      32             :         NVMF_TGT_RUNNING,
      33             :         NVMF_TGT_PAUSING,
      34             :         NVMF_TGT_PAUSED,
      35             :         NVMF_TGT_RESUMING,
      36             : };
      37             : 
      38             : enum spdk_nvmf_subsystem_state {
      39             :         SPDK_NVMF_SUBSYSTEM_INACTIVE = 0,
      40             :         SPDK_NVMF_SUBSYSTEM_ACTIVATING,
      41             :         SPDK_NVMF_SUBSYSTEM_ACTIVE,
      42             :         SPDK_NVMF_SUBSYSTEM_PAUSING,
      43             :         SPDK_NVMF_SUBSYSTEM_PAUSED,
      44             :         SPDK_NVMF_SUBSYSTEM_RESUMING,
      45             :         SPDK_NVMF_SUBSYSTEM_DEACTIVATING,
      46             :         SPDK_NVMF_SUBSYSTEM_NUM_STATES,
      47             : };
      48             : 
      49             : RB_HEAD(subsystem_tree, spdk_nvmf_subsystem);
      50             : 
      51             : struct spdk_nvmf_tgt {
      52             :         char                                    name[NVMF_TGT_NAME_MAX_LENGTH];
      53             : 
      54             :         pthread_mutex_t                         mutex;
      55             : 
      56             :         uint64_t                                discovery_genctr;
      57             : 
      58             :         uint32_t                                max_subsystems;
      59             : 
      60             :         uint32_t                                discovery_filter;
      61             : 
      62             :         enum spdk_nvmf_tgt_state                state;
      63             : 
      64             :         struct spdk_bit_array                   *subsystem_ids;
      65             : 
      66             :         struct subsystem_tree                   subsystems;
      67             : 
      68             :         TAILQ_HEAD(, spdk_nvmf_transport)       transports;
      69             :         TAILQ_HEAD(, spdk_nvmf_poll_group)      poll_groups;
      70             :         TAILQ_HEAD(, spdk_nvmf_referral)        referrals;
      71             : 
      72             :         /* Used for round-robin assignment of connections to poll groups */
      73             :         struct spdk_nvmf_poll_group             *next_poll_group;
      74             : 
      75             :         spdk_nvmf_tgt_destroy_done_fn           *destroy_cb_fn;
      76             :         void                                    *destroy_cb_arg;
      77             : 
      78             :         uint16_t                                crdt[3];
      79             :         uint16_t                                num_poll_groups;
      80             : 
      81             :         /* Allowed DH-HMAC-CHAP digests/dhgroups */
      82             :         uint32_t                                dhchap_digests;
      83             :         uint32_t                                dhchap_dhgroups;
      84             : 
      85             :         TAILQ_ENTRY(spdk_nvmf_tgt)              link;
      86             : };
      87             : 
      88             : struct spdk_nvmf_host {
      89             :         char                            nqn[SPDK_NVMF_NQN_MAX_LEN + 1];
      90             :         struct spdk_key                 *dhchap_key;
      91             :         struct spdk_key                 *dhchap_ctrlr_key;
      92             :         TAILQ_ENTRY(spdk_nvmf_host)     link;
      93             : };
      94             : 
      95             : struct spdk_nvmf_subsystem_listener {
      96             :         struct spdk_nvmf_subsystem                      *subsystem;
      97             :         spdk_nvmf_tgt_subsystem_listen_done_fn          cb_fn;
      98             :         void                                            *cb_arg;
      99             :         struct spdk_nvme_transport_id                   *trid;
     100             :         struct spdk_nvmf_transport                      *transport;
     101             :         enum spdk_nvme_ana_state                        *ana_state;
     102             :         uint64_t                                        ana_state_change_count;
     103             :         uint16_t                                        id;
     104             :         struct spdk_nvmf_listener_opts                  opts;
     105             :         TAILQ_ENTRY(spdk_nvmf_subsystem_listener)       link;
     106             : };
     107             : 
     108             : struct spdk_nvmf_referral {
     109             :         /* Discovery Log Page Entry for this referral */
     110             :         struct spdk_nvmf_discovery_log_page_entry entry;
     111             :         /* Transport ID */
     112             :         struct spdk_nvme_transport_id trid;
     113             :         TAILQ_ENTRY(spdk_nvmf_referral) link;
     114             : };
     115             : 
     116             : struct spdk_nvmf_subsystem_pg_ns_info {
     117             :         struct spdk_io_channel          *channel;
     118             :         struct spdk_uuid                uuid;
     119             :         /* current reservation key, no reservation if the value is 0 */
     120             :         uint64_t                        crkey;
     121             :         /* reservation type */
     122             :         enum spdk_nvme_reservation_type rtype;
     123             :         /* Host ID which holds the reservation */
     124             :         struct spdk_uuid                holder_id;
     125             :         /* Host ID for the registrants with the namespace */
     126             :         struct spdk_uuid                reg_hostid[SPDK_NVMF_MAX_NUM_REGISTRANTS];
     127             :         uint64_t                        num_blocks;
     128             : 
     129             :         /* I/O outstanding to this namespace */
     130             :         uint64_t                        io_outstanding;
     131             :         enum spdk_nvmf_subsystem_state  state;
     132             : };
     133             : 
     134             : typedef void(*spdk_nvmf_poll_group_mod_done)(void *cb_arg, int status);
     135             : 
     136             : struct spdk_nvmf_subsystem_poll_group {
     137             :         /* Array of namespace information for each namespace indexed by nsid - 1 */
     138             :         struct spdk_nvmf_subsystem_pg_ns_info   *ns_info;
     139             :         uint32_t                                num_ns;
     140             :         enum spdk_nvmf_subsystem_state          state;
     141             : 
     142             :         /* Number of ADMIN and FABRICS requests outstanding */
     143             :         uint64_t                                mgmt_io_outstanding;
     144             :         spdk_nvmf_poll_group_mod_done           cb_fn;
     145             :         void                                    *cb_arg;
     146             : 
     147             :         TAILQ_HEAD(, spdk_nvmf_request)         queued;
     148             : };
     149             : 
     150             : struct spdk_nvmf_registrant {
     151             :         TAILQ_ENTRY(spdk_nvmf_registrant) link;
     152             :         struct spdk_uuid hostid;
     153             :         /* Registration key */
     154             :         uint64_t rkey;
     155             : };
     156             : 
     157             : struct spdk_nvmf_ns {
     158             :         uint32_t nsid;
     159             :         uint32_t anagrpid;
     160             :         struct spdk_nvmf_subsystem *subsystem;
     161             :         struct spdk_bdev *bdev;
     162             :         struct spdk_bdev_desc *desc;
     163             :         struct spdk_nvmf_ns_opts opts;
     164             :         /* reservation notification mask */
     165             :         uint32_t mask;
     166             :         /* generation code */
     167             :         uint32_t gen;
     168             :         /* registrants head */
     169             :         TAILQ_HEAD(, spdk_nvmf_registrant) registrants;
     170             :         /* current reservation key */
     171             :         uint64_t crkey;
     172             :         /* reservation type */
     173             :         enum spdk_nvme_reservation_type rtype;
     174             :         /* current reservation holder, only valid if reservation type can only have one holder */
     175             :         struct spdk_nvmf_registrant *holder;
     176             :         /* Persist Through Power Loss file which contains the persistent reservation */
     177             :         char *ptpl_file;
     178             :         /* Persist Through Power Loss feature is enabled */
     179             :         bool ptpl_activated;
     180             :         /* ZCOPY supported on bdev device */
     181             :         bool zcopy;
     182             :         /* Command Set Identifier */
     183             :         enum spdk_nvme_csi csi;
     184             :         /* Make namespace visible to controllers of these hosts */
     185             :         TAILQ_HEAD(, spdk_nvmf_host) hosts;
     186             :         /* Namespace is always visible to all controllers */
     187             :         bool always_visible;
     188             : };
     189             : 
     190             : /*
     191             :  * NVMf reservation notification log page.
     192             :  */
     193             : struct spdk_nvmf_reservation_log {
     194             :         struct spdk_nvme_reservation_notification_log   log;
     195             :         TAILQ_ENTRY(spdk_nvmf_reservation_log)          link;
     196             :         struct spdk_nvmf_ctrlr                          *ctrlr;
     197             : };
     198             : 
     199             : /*
     200             :  * NVMf async event completion.
     201             :  */
     202             : struct spdk_nvmf_async_event_completion {
     203             :         union spdk_nvme_async_event_completion          event;
     204             :         STAILQ_ENTRY(spdk_nvmf_async_event_completion)  link;
     205             : };
     206             : 
     207             : /*
     208             :  * This structure represents an NVMe-oF controller,
     209             :  * which is like a "session" in networking terms.
     210             :  */
     211             : struct spdk_nvmf_ctrlr {
     212             :         uint16_t                        cntlid;
     213             :         char                            hostnqn[SPDK_NVMF_NQN_MAX_LEN + 1];
     214             :         struct spdk_nvmf_subsystem      *subsys;
     215             :         struct spdk_bit_array           *visible_ns;
     216             : 
     217             :         struct spdk_nvmf_ctrlr_data     cdata;
     218             : 
     219             :         struct spdk_nvmf_registers      vcprop;
     220             : 
     221             :         struct spdk_nvmf_ctrlr_feat feat;
     222             : 
     223             :         struct spdk_nvmf_qpair  *admin_qpair;
     224             :         struct spdk_thread      *thread;
     225             :         struct spdk_bit_array   *qpair_mask;
     226             : 
     227             :         const struct spdk_nvmf_subsystem_listener       *listener;
     228             : 
     229             :         struct spdk_nvmf_request *aer_req[SPDK_NVMF_MAX_ASYNC_EVENTS];
     230             :         STAILQ_HEAD(, spdk_nvmf_async_event_completion) async_events;
     231             :         uint64_t notice_aen_mask;
     232             :         uint8_t nr_aer_reqs;
     233             :         struct spdk_uuid  hostid;
     234             : 
     235             :         uint32_t association_timeout; /* in milliseconds */
     236             :         uint16_t changed_ns_list_count;
     237             :         struct spdk_nvme_ns_list changed_ns_list;
     238             :         uint64_t log_page_count;
     239             :         uint8_t num_avail_log_pages;
     240             :         TAILQ_HEAD(log_page_head, spdk_nvmf_reservation_log) log_head;
     241             : 
     242             :         /* Time to trigger keep-alive--poller_time = now_tick + period */
     243             :         uint64_t                        last_keep_alive_tick;
     244             :         struct spdk_poller              *keep_alive_poller;
     245             : 
     246             :         struct spdk_poller              *association_timer;
     247             : 
     248             :         struct spdk_poller              *cc_timer;
     249             :         uint64_t                        cc_timeout_tsc;
     250             :         struct spdk_poller              *cc_timeout_timer;
     251             : 
     252             :         bool                            dif_insert_or_strip;
     253             :         bool                            in_destruct;
     254             :         bool                            disconnect_in_progress;
     255             :         /* valid only when disconnect_in_progress is true */
     256             :         bool                            disconnect_is_shn;
     257             :         bool                            acre_enabled;
     258             :         bool                            dynamic_ctrlr;
     259             : 
     260             :         TAILQ_ENTRY(spdk_nvmf_ctrlr)    link;
     261             : };
     262             : 
     263             : #define NVMF_MAX_LISTENERS_PER_SUBSYSTEM        16
     264             : 
     265             : struct nvmf_subsystem_state_change_ctx {
     266             :         struct spdk_nvmf_subsystem                      *subsystem;
     267             :         uint16_t                                        nsid;
     268             : 
     269             :         enum spdk_nvmf_subsystem_state                  original_state;
     270             :         enum spdk_nvmf_subsystem_state                  requested_state;
     271             :         int                                             status;
     272             :         struct spdk_thread                              *thread;
     273             : 
     274             :         spdk_nvmf_subsystem_state_change_done           cb_fn;
     275             :         void                                            *cb_arg;
     276             :         TAILQ_ENTRY(nvmf_subsystem_state_change_ctx)    link;
     277             : };
     278             : 
     279             : struct spdk_nvmf_subsystem {
     280             :         struct spdk_thread                              *thread;
     281             : 
     282             :         uint32_t                                        id;
     283             : 
     284             :         enum spdk_nvmf_subsystem_state                  state;
     285             :         enum spdk_nvmf_subtype                          subtype;
     286             : 
     287             :         uint16_t                                        next_cntlid;
     288             :         struct {
     289             :                 uint8_t                                 allow_any_listener : 1;
     290             :                 uint8_t                                 ana_reporting : 1;
     291             :                 uint8_t                                 reserved : 6;
     292             :         } flags;
     293             : 
     294             :         /* Protected against concurrent access by ->mutex */
     295             :         bool                                            allow_any_host;
     296             : 
     297             :         bool                                            destroying;
     298             :         bool                                            async_destroy;
     299             : 
     300             :         /* FDP related fields */
     301             :         bool                                            fdp_supported;
     302             : 
     303             :         /* Zoned storage related fields */
     304             :         bool                                            zone_append_supported;
     305             :         uint64_t                                        max_zone_append_size_kib;
     306             : 
     307             :         struct spdk_nvmf_tgt                            *tgt;
     308             :         RB_ENTRY(spdk_nvmf_subsystem)                   link;
     309             : 
     310             :         /* Array of pointers to namespaces of size max_nsid indexed by nsid - 1 */
     311             :         struct spdk_nvmf_ns                             **ns;
     312             :         uint32_t                                        max_nsid;
     313             : 
     314             :         uint16_t                                        min_cntlid;
     315             :         uint16_t                                        max_cntlid;
     316             : 
     317             :         uint64_t                                        max_discard_size_kib;
     318             :         uint64_t                                        max_write_zeroes_size_kib;
     319             : 
     320             :         TAILQ_HEAD(, spdk_nvmf_ctrlr)                   ctrlrs;
     321             : 
     322             :         /* This mutex is used to protect fields that aren't touched on the I/O path (e.g. it's
     323             :          * needed for handling things like the CONNECT command) instead of requiring the subsystem
     324             :          * to be paused.  It makes it possible to modify those fields (e.g. add/remove hosts)
     325             :          * without affecting outstanding I/O requests.
     326             :          */
     327             :         pthread_mutex_t                                 mutex;
     328             :         /* Protected against concurrent access by ->mutex */
     329             :         TAILQ_HEAD(, spdk_nvmf_host)                    hosts;
     330             :         TAILQ_HEAD(, spdk_nvmf_subsystem_listener)      listeners;
     331             :         struct spdk_bit_array                           *used_listener_ids;
     332             : 
     333             :         TAILQ_ENTRY(spdk_nvmf_subsystem)                entries;
     334             : 
     335             :         nvmf_subsystem_destroy_cb                       async_destroy_cb;
     336             :         void                                            *async_destroy_cb_arg;
     337             : 
     338             :         char                                            sn[SPDK_NVME_CTRLR_SN_LEN + 1];
     339             :         char                                            mn[SPDK_NVME_CTRLR_MN_LEN + 1];
     340             :         char                                            subnqn[SPDK_NVMF_NQN_MAX_LEN + 1];
     341             : 
     342             :         /* Array of namespace count per ANA group of size max_nsid indexed anagrpid - 1
     343             :          * It will be enough for ANA group to use the same size as namespaces.
     344             :          */
     345             :         uint32_t                                        *ana_group;
     346             :         /* Queue of a state change requests */
     347             :         TAILQ_HEAD(, nvmf_subsystem_state_change_ctx)   state_changes;
     348             :         /* In-band authentication sequence number, protected by ->mutex */
     349             :         uint32_t                                        auth_seqnum;
     350             : };
     351             : 
     352             : static int
     353           1 : subsystem_cmp(struct spdk_nvmf_subsystem *subsystem1, struct spdk_nvmf_subsystem *subsystem2)
     354             : {
     355           1 :         return strncmp(subsystem1->subnqn, subsystem2->subnqn, sizeof(subsystem1->subnqn));
     356             : }
     357             : 
     358         142 : RB_GENERATE_STATIC(subsystem_tree, spdk_nvmf_subsystem, link, subsystem_cmp);
     359             : 
     360             : int nvmf_poll_group_update_subsystem(struct spdk_nvmf_poll_group *group,
     361             :                                      struct spdk_nvmf_subsystem *subsystem);
     362             : int nvmf_poll_group_add_subsystem(struct spdk_nvmf_poll_group *group,
     363             :                                   struct spdk_nvmf_subsystem *subsystem,
     364             :                                   spdk_nvmf_poll_group_mod_done cb_fn, void *cb_arg);
     365             : void nvmf_poll_group_remove_subsystem(struct spdk_nvmf_poll_group *group,
     366             :                                       struct spdk_nvmf_subsystem *subsystem, spdk_nvmf_poll_group_mod_done cb_fn, void *cb_arg);
     367             : void nvmf_poll_group_pause_subsystem(struct spdk_nvmf_poll_group *group,
     368             :                                      struct spdk_nvmf_subsystem *subsystem,
     369             :                                      uint32_t nsid,
     370             :                                      spdk_nvmf_poll_group_mod_done cb_fn, void *cb_arg);
     371             : void nvmf_poll_group_resume_subsystem(struct spdk_nvmf_poll_group *group,
     372             :                                       struct spdk_nvmf_subsystem *subsystem, spdk_nvmf_poll_group_mod_done cb_fn, void *cb_arg);
     373             : 
     374             : void nvmf_update_discovery_log(struct spdk_nvmf_tgt *tgt, const char *hostnqn);
     375             : void nvmf_get_discovery_log_page(struct spdk_nvmf_tgt *tgt, const char *hostnqn, struct iovec *iov,
     376             :                                  uint32_t iovcnt, uint64_t offset, uint32_t length,
     377             :                                  struct spdk_nvme_transport_id *cmd_source_trid);
     378             : 
     379             : void nvmf_ctrlr_destruct(struct spdk_nvmf_ctrlr *ctrlr);
     380             : int nvmf_ctrlr_process_admin_cmd(struct spdk_nvmf_request *req);
     381             : int nvmf_ctrlr_process_io_cmd(struct spdk_nvmf_request *req);
     382             : bool nvmf_ctrlr_dsm_supported(struct spdk_nvmf_ctrlr *ctrlr);
     383             : bool nvmf_ctrlr_write_zeroes_supported(struct spdk_nvmf_ctrlr *ctrlr);
     384             : bool nvmf_ctrlr_copy_supported(struct spdk_nvmf_ctrlr *ctrlr);
     385             : void nvmf_ctrlr_ns_changed(struct spdk_nvmf_ctrlr *ctrlr, uint32_t nsid);
     386             : bool nvmf_ctrlr_use_zcopy(struct spdk_nvmf_request *req);
     387             : 
     388             : void nvmf_bdev_ctrlr_identify_ns(struct spdk_nvmf_ns *ns, struct spdk_nvme_ns_data *nsdata,
     389             :                                  bool dif_insert_or_strip);
     390             : int nvmf_bdev_ctrlr_read_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
     391             :                              struct spdk_io_channel *ch, struct spdk_nvmf_request *req);
     392             : int nvmf_bdev_ctrlr_write_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
     393             :                               struct spdk_io_channel *ch, struct spdk_nvmf_request *req);
     394             : int nvmf_bdev_ctrlr_compare_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
     395             :                                 struct spdk_io_channel *ch, struct spdk_nvmf_request *req);
     396             : int nvmf_bdev_ctrlr_compare_and_write_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
     397             :                 struct spdk_io_channel *ch, struct spdk_nvmf_request *cmp_req, struct spdk_nvmf_request *write_req);
     398             : int nvmf_bdev_ctrlr_write_zeroes_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
     399             :                                      struct spdk_io_channel *ch, struct spdk_nvmf_request *req);
     400             : int nvmf_bdev_ctrlr_flush_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
     401             :                               struct spdk_io_channel *ch, struct spdk_nvmf_request *req);
     402             : int nvmf_bdev_ctrlr_dsm_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
     403             :                             struct spdk_io_channel *ch, struct spdk_nvmf_request *req);
     404             : int nvmf_bdev_ctrlr_copy_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
     405             :                              struct spdk_io_channel *ch, struct spdk_nvmf_request *req);
     406             : int nvmf_bdev_ctrlr_nvme_passthru_io(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
     407             :                                      struct spdk_io_channel *ch, struct spdk_nvmf_request *req);
     408             : bool nvmf_bdev_ctrlr_get_dif_ctx(struct spdk_bdev *bdev, struct spdk_nvme_cmd *cmd,
     409             :                                  struct spdk_dif_ctx *dif_ctx);
     410             : bool nvmf_bdev_zcopy_enabled(struct spdk_bdev *bdev);
     411             : 
     412             : int nvmf_subsystem_add_ctrlr(struct spdk_nvmf_subsystem *subsystem,
     413             :                              struct spdk_nvmf_ctrlr *ctrlr);
     414             : void nvmf_subsystem_remove_ctrlr(struct spdk_nvmf_subsystem *subsystem,
     415             :                                  struct spdk_nvmf_ctrlr *ctrlr);
     416             : void nvmf_subsystem_remove_all_listeners(struct spdk_nvmf_subsystem *subsystem,
     417             :                 bool stop);
     418             : struct spdk_nvmf_ctrlr *nvmf_subsystem_get_ctrlr(struct spdk_nvmf_subsystem *subsystem,
     419             :                 uint16_t cntlid);
     420             : bool nvmf_subsystem_host_auth_required(struct spdk_nvmf_subsystem *subsystem, const char *hostnqn);
     421             : enum nvmf_auth_key_type {
     422             :         NVMF_AUTH_KEY_HOST,
     423             :         NVMF_AUTH_KEY_CTRLR,
     424             : };
     425             : struct spdk_key *nvmf_subsystem_get_dhchap_key(struct spdk_nvmf_subsystem *subsys, const char *nqn,
     426             :                 enum nvmf_auth_key_type type);
     427             : struct spdk_nvmf_subsystem_listener *nvmf_subsystem_find_listener(
     428             :         struct spdk_nvmf_subsystem *subsystem,
     429             :         const struct spdk_nvme_transport_id *trid);
     430             : struct spdk_nvmf_listener *nvmf_transport_find_listener(
     431             :         struct spdk_nvmf_transport *transport,
     432             :         const struct spdk_nvme_transport_id *trid);
     433             : void nvmf_transport_dump_opts(struct spdk_nvmf_transport *transport, struct spdk_json_write_ctx *w,
     434             :                               bool named);
     435             : void nvmf_transport_listen_dump_trid(const struct spdk_nvme_transport_id *trid,
     436             :                                      struct spdk_json_write_ctx *w);
     437             : 
     438             : /**
     439             :  * Sets the controller ID range for a subsystem.
     440             :  * Valid range is [1, 0xFFEF].
     441             :  *
     442             :  * May only be performed on subsystems in the INACTIVE state.
     443             :  *
     444             :  * \param subsystem Subsystem to modify.
     445             :  * \param min_cntlid Minimum controller ID.
     446             :  * \param max_cntlid Maximum controller ID.
     447             :  *
     448             :  * \return 0 on success, or negated errno value on failure.
     449             :  */
     450             : int nvmf_subsystem_set_cntlid_range(struct spdk_nvmf_subsystem *subsystem,
     451             :                                     uint16_t min_cntlid, uint16_t max_cntlid);
     452             : 
     453             : int nvmf_ctrlr_async_event_ns_notice(struct spdk_nvmf_ctrlr *ctrlr);
     454             : int nvmf_ctrlr_async_event_ana_change_notice(struct spdk_nvmf_ctrlr *ctrlr);
     455             : void nvmf_ctrlr_async_event_discovery_log_change_notice(void *ctx);
     456             : void nvmf_ctrlr_async_event_reservation_notification(struct spdk_nvmf_ctrlr *ctrlr);
     457             : 
     458             : void nvmf_ns_reservation_request(void *ctx);
     459             : void nvmf_ctrlr_reservation_notice_log(struct spdk_nvmf_ctrlr *ctrlr,
     460             :                                        struct spdk_nvmf_ns *ns,
     461             :                                        enum spdk_nvme_reservation_notification_log_page_type type);
     462             : 
     463             : bool nvmf_ns_is_ptpl_capable(const struct spdk_nvmf_ns *ns);
     464             : 
     465             : static inline struct spdk_nvmf_host *
     466          43 : nvmf_ns_find_host(struct spdk_nvmf_ns *ns, const char *hostnqn)
     467             : {
     468          43 :         struct spdk_nvmf_host *host = NULL;
     469             : 
     470          46 :         TAILQ_FOREACH(host, &ns->hosts, link) {
     471          11 :                 if (strcmp(hostnqn, host->nqn) == 0) {
     472           8 :                         return host;
     473             :                 }
     474             :         }
     475             : 
     476          35 :         return NULL;
     477             : }
     478             : 
     479             : /*
     480             :  * Abort zero-copy requests that already got the buffer (received zcopy_start cb), but haven't
     481             :  * started zcopy_end.  These requests are kept on the outstanding queue, but are not waiting for a
     482             :  * completion from the bdev layer, so, when a qpair is being disconnected, we need to kick them to
     483             :  * force their completion.
     484             :  */
     485             : void nvmf_qpair_abort_pending_zcopy_reqs(struct spdk_nvmf_qpair *qpair);
     486             : 
     487             : /*
     488             :  * Free aer simply frees the rdma resources for the aer without informing the host.
     489             :  * This function should be called when deleting a qpair when one wants to make sure
     490             :  * the qpair is completely empty before freeing the request. The reason we free the
     491             :  * AER without sending a completion is to prevent the host from sending another AER.
     492             :  */
     493             : void nvmf_qpair_free_aer(struct spdk_nvmf_qpair *qpair);
     494             : 
     495             : int nvmf_ctrlr_abort_request(struct spdk_nvmf_request *req);
     496             : 
     497             : void nvmf_ctrlr_set_fatal_status(struct spdk_nvmf_ctrlr *ctrlr);
     498             : 
     499             : static inline bool
     500          48 : nvmf_ctrlr_ns_is_visible(struct spdk_nvmf_ctrlr *ctrlr, uint32_t nsid)
     501             : {
     502          48 :         return spdk_bit_array_get(ctrlr->visible_ns, nsid - 1);
     503             : }
     504             : 
     505             : static inline struct spdk_nvmf_ns *
     506          77 : _nvmf_subsystem_get_ns(struct spdk_nvmf_subsystem *subsystem, uint32_t nsid)
     507             : {
     508             :         /* NOTE: This implicitly also checks for 0, since 0 - 1 wraps around to UINT32_MAX. */
     509          77 :         if (spdk_unlikely(nsid - 1 >= subsystem->max_nsid)) {
     510          22 :                 return NULL;
     511             :         }
     512             : 
     513          55 :         return subsystem->ns[nsid - 1];
     514             : }
     515             : 
     516             : static inline struct spdk_nvmf_ns *
     517          49 : nvmf_ctrlr_get_ns(struct spdk_nvmf_ctrlr *ctrlr, uint32_t nsid)
     518             : {
     519          49 :         struct spdk_nvmf_subsystem *subsystem = ctrlr->subsys;
     520          49 :         struct spdk_nvmf_ns *ns = _nvmf_subsystem_get_ns(subsystem, nsid);
     521             : 
     522          49 :         return ns && nvmf_ctrlr_ns_is_visible(ctrlr, nsid) ? ns : NULL;
     523             : }
     524             : 
     525             : static inline bool
     526         313 : nvmf_qpair_is_admin_queue(struct spdk_nvmf_qpair *qpair)
     527             : {
     528         313 :         return qpair->qid == 0;
     529             : }
     530             : 
     531             : void nvmf_qpair_set_state(struct spdk_nvmf_qpair *qpair, enum spdk_nvmf_qpair_state state);
     532             : 
     533             : int nvmf_qpair_auth_init(struct spdk_nvmf_qpair *qpair);
     534             : void nvmf_qpair_auth_destroy(struct spdk_nvmf_qpair *qpair);
     535             : void nvmf_qpair_auth_dump(struct spdk_nvmf_qpair *qpair, struct spdk_json_write_ctx *w);
     536             : 
     537             : int nvmf_auth_request_exec(struct spdk_nvmf_request *req);
     538             : bool nvmf_auth_is_supported(void);
     539             : 
     540             : static inline bool
     541          27 : nvmf_request_is_fabric_connect(struct spdk_nvmf_request *req)
     542             : {
     543          45 :         return req->cmd->nvmf_cmd.opcode == SPDK_NVME_OPC_FABRIC &&
     544          18 :                req->cmd->nvmf_cmd.fctype == SPDK_NVMF_FABRIC_COMMAND_CONNECT;
     545             : }
     546             : 
     547             : /*
     548             :  * Tests whether a given string represents a valid NQN.
     549             :  */
     550             : bool nvmf_nqn_is_valid(const char *nqn);
     551             : 
     552             : /*
     553             :  * Tests whether a given NQN describes a discovery subsystem.
     554             :  */
     555             : bool nvmf_nqn_is_discovery(const char *nqn);
     556             : 
     557             : /**
     558             :  * Initiates a zcopy start operation
     559             :  *
     560             :  * \param bdev The \ref spdk_bdev
     561             :  * \param desc The \ref spdk_bdev_desc
     562             :  * \param ch The \ref spdk_io_channel
     563             :  * \param req The \ref spdk_nvmf_request passed to the bdev for processing
     564             :  *
     565             :  * \return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE if the command was completed immediately or
     566             :  *         SPDK_NVMF_REQUEST_EXEC_STATUS_ASYNCHRONOUS if the command was submitted and will be
     567             :  *         completed asynchronously.  Asynchronous completions are notified through
     568             :  *         spdk_nvmf_request_complete().
     569             :  */
     570             : int nvmf_bdev_ctrlr_zcopy_start(struct spdk_bdev *bdev,
     571             :                                 struct spdk_bdev_desc *desc,
     572             :                                 struct spdk_io_channel *ch,
     573             :                                 struct spdk_nvmf_request *req);
     574             : 
     575             : /**
     576             :  * Ends a zcopy operation
     577             :  *
     578             :  * \param req The NVMe-oF request
     579             :  * \param commit Flag indicating whether the buffers should be committed
     580             :  */
     581             : void nvmf_bdev_ctrlr_zcopy_end(struct spdk_nvmf_request *req, bool commit);
     582             : 
     583             : /**
     584             :  * Publishes the mDNS PRR (Pull Registration Request) for the NVMe-oF target.
     585             :  *
     586             :  * \param tgt The NVMe-oF target
     587             :  *
     588             :  * \return 0 on success, negative errno on failure
     589             :  */
     590             : int nvmf_publish_mdns_prr(struct spdk_nvmf_tgt *tgt);
     591             : 
     592             : /**
     593             :  * Stops the mDNS PRR (Pull Registration Request) for the NVMe-oF target.
     594             :  *
     595             :  * \param tgt The NVMe-oF target
     596             :  */
     597             : void nvmf_tgt_stop_mdns_prr(struct spdk_nvmf_tgt *tgt);
     598             : 
     599             : #endif /* __NVMF_INTERNAL_H__ */

Generated by: LCOV version 1.15