Skip to content

Commit 15e9d26

Browse files
damien-lemoalkeithbusch
authored andcommitted
nvmet: Export nvmet_update_cc() and nvmet_cc_xxx() helpers
Make the function nvmet_update_cc() available to target drivers by exporting it. To also facilitate the manipulation of the cc register bits, move the inline helper functions nvmet_cc_en(), nvmet_cc_css(), nvmet_cc_mps(), nvmet_cc_ams(), nvmet_cc_shn(), nvmet_cc_iosqes(), and nvmet_cc_iocqes() from core.c to nvmet.h so that these functions can be reused in target controller drivers. Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Tested-by: Rick Wertenbroek <[email protected]> Tested-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 5d4f4ea commit 15e9d26

File tree

2 files changed

+36
-35
lines changed

2 files changed

+36
-35
lines changed

drivers/nvme/target/core.c

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,41 +1166,6 @@ void nvmet_req_free_sgls(struct nvmet_req *req)
11661166
}
11671167
EXPORT_SYMBOL_GPL(nvmet_req_free_sgls);
11681168

1169-
static inline bool nvmet_cc_en(u32 cc)
1170-
{
1171-
return (cc >> NVME_CC_EN_SHIFT) & 0x1;
1172-
}
1173-
1174-
static inline u8 nvmet_cc_css(u32 cc)
1175-
{
1176-
return (cc >> NVME_CC_CSS_SHIFT) & 0x7;
1177-
}
1178-
1179-
static inline u8 nvmet_cc_mps(u32 cc)
1180-
{
1181-
return (cc >> NVME_CC_MPS_SHIFT) & 0xf;
1182-
}
1183-
1184-
static inline u8 nvmet_cc_ams(u32 cc)
1185-
{
1186-
return (cc >> NVME_CC_AMS_SHIFT) & 0x7;
1187-
}
1188-
1189-
static inline u8 nvmet_cc_shn(u32 cc)
1190-
{
1191-
return (cc >> NVME_CC_SHN_SHIFT) & 0x3;
1192-
}
1193-
1194-
static inline u8 nvmet_cc_iosqes(u32 cc)
1195-
{
1196-
return (cc >> NVME_CC_IOSQES_SHIFT) & 0xf;
1197-
}
1198-
1199-
static inline u8 nvmet_cc_iocqes(u32 cc)
1200-
{
1201-
return (cc >> NVME_CC_IOCQES_SHIFT) & 0xf;
1202-
}
1203-
12041169
static inline bool nvmet_css_supported(u8 cc_css)
12051170
{
12061171
switch (cc_css << NVME_CC_CSS_SHIFT) {
@@ -1277,6 +1242,7 @@ void nvmet_update_cc(struct nvmet_ctrl *ctrl, u32 new)
12771242
ctrl->csts &= ~NVME_CSTS_SHST_CMPLT;
12781243
mutex_unlock(&ctrl->lock);
12791244
}
1245+
EXPORT_SYMBOL_GPL(nvmet_update_cc);
12801246

12811247
static void nvmet_init_cap(struct nvmet_ctrl *ctrl)
12821248
{

drivers/nvme/target/nvmet.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,41 @@ void nvmet_passthrough_override_cap(struct nvmet_ctrl *ctrl);
732732
u16 errno_to_nvme_status(struct nvmet_req *req, int errno);
733733
u16 nvmet_report_invalid_opcode(struct nvmet_req *req);
734734

735+
static inline bool nvmet_cc_en(u32 cc)
736+
{
737+
return (cc >> NVME_CC_EN_SHIFT) & 0x1;
738+
}
739+
740+
static inline u8 nvmet_cc_css(u32 cc)
741+
{
742+
return (cc >> NVME_CC_CSS_SHIFT) & 0x7;
743+
}
744+
745+
static inline u8 nvmet_cc_mps(u32 cc)
746+
{
747+
return (cc >> NVME_CC_MPS_SHIFT) & 0xf;
748+
}
749+
750+
static inline u8 nvmet_cc_ams(u32 cc)
751+
{
752+
return (cc >> NVME_CC_AMS_SHIFT) & 0x7;
753+
}
754+
755+
static inline u8 nvmet_cc_shn(u32 cc)
756+
{
757+
return (cc >> NVME_CC_SHN_SHIFT) & 0x3;
758+
}
759+
760+
static inline u8 nvmet_cc_iosqes(u32 cc)
761+
{
762+
return (cc >> NVME_CC_IOSQES_SHIFT) & 0xf;
763+
}
764+
765+
static inline u8 nvmet_cc_iocqes(u32 cc)
766+
{
767+
return (cc >> NVME_CC_IOCQES_SHIFT) & 0xf;
768+
}
769+
735770
/* Convert a 32-bit number to a 16-bit 0's based number */
736771
static inline __le16 to0based(u32 a)
737772
{

0 commit comments

Comments
 (0)