@@ -38,7 +38,8 @@ void gve_parse_device_option(struct gve_priv *priv,
3838 struct gve_device_option * option ,
3939 struct gve_device_option_gqi_rda * * dev_op_gqi_rda ,
4040 struct gve_device_option_gqi_qpl * * dev_op_gqi_qpl ,
41- struct gve_device_option_dqo_rda * * dev_op_dqo_rda )
41+ struct gve_device_option_dqo_rda * * dev_op_dqo_rda ,
42+ struct gve_device_option_jumbo_frames * * dev_op_jumbo_frames )
4243{
4344 u32 req_feat_mask = be32_to_cpu (option -> required_features_mask );
4445 u16 option_length = be16_to_cpu (option -> option_length );
@@ -111,6 +112,24 @@ void gve_parse_device_option(struct gve_priv *priv,
111112 }
112113 * dev_op_dqo_rda = (void * )(option + 1 );
113114 break ;
115+ case GVE_DEV_OPT_ID_JUMBO_FRAMES :
116+ if (option_length < sizeof (* * dev_op_jumbo_frames ) ||
117+ req_feat_mask != GVE_DEV_OPT_REQ_FEAT_MASK_JUMBO_FRAMES ) {
118+ dev_warn (& priv -> pdev -> dev , GVE_DEVICE_OPTION_ERROR_FMT ,
119+ "Jumbo Frames" ,
120+ (int )sizeof (* * dev_op_jumbo_frames ),
121+ GVE_DEV_OPT_REQ_FEAT_MASK_JUMBO_FRAMES ,
122+ option_length , req_feat_mask );
123+ break ;
124+ }
125+
126+ if (option_length > sizeof (* * dev_op_jumbo_frames )) {
127+ dev_warn (& priv -> pdev -> dev ,
128+ GVE_DEVICE_OPTION_TOO_BIG_FMT ,
129+ "Jumbo Frames" );
130+ }
131+ * dev_op_jumbo_frames = (void * )(option + 1 );
132+ break ;
114133 default :
115134 /* If we don't recognize the option just continue
116135 * without doing anything.
@@ -126,7 +145,8 @@ gve_process_device_options(struct gve_priv *priv,
126145 struct gve_device_descriptor * descriptor ,
127146 struct gve_device_option_gqi_rda * * dev_op_gqi_rda ,
128147 struct gve_device_option_gqi_qpl * * dev_op_gqi_qpl ,
129- struct gve_device_option_dqo_rda * * dev_op_dqo_rda )
148+ struct gve_device_option_dqo_rda * * dev_op_dqo_rda ,
149+ struct gve_device_option_jumbo_frames * * dev_op_jumbo_frames )
130150{
131151 const int num_options = be16_to_cpu (descriptor -> num_device_options );
132152 struct gve_device_option * dev_opt ;
@@ -146,7 +166,7 @@ gve_process_device_options(struct gve_priv *priv,
146166
147167 gve_parse_device_option (priv , descriptor , dev_opt ,
148168 dev_op_gqi_rda , dev_op_gqi_qpl ,
149- dev_op_dqo_rda );
169+ dev_op_dqo_rda , dev_op_jumbo_frames );
150170 dev_opt = next_opt ;
151171 }
152172
@@ -661,12 +681,31 @@ gve_set_desc_cnt_dqo(struct gve_priv *priv,
661681 return 0 ;
662682}
663683
684+ static void gve_enable_supported_features (struct gve_priv * priv ,
685+ u32 supported_features_mask ,
686+ const struct gve_device_option_jumbo_frames
687+ * dev_op_jumbo_frames )
688+ {
689+ /* Before control reaches this point, the page-size-capped max MTU from
690+ * the gve_device_descriptor field has already been stored in
691+ * priv->dev->max_mtu. We overwrite it with the true max MTU below.
692+ */
693+ if (dev_op_jumbo_frames &&
694+ (supported_features_mask & GVE_SUP_JUMBO_FRAMES_MASK )) {
695+ dev_info (& priv -> pdev -> dev ,
696+ "JUMBO FRAMES device option enabled.\n" );
697+ priv -> dev -> max_mtu = be16_to_cpu (dev_op_jumbo_frames -> max_mtu );
698+ }
699+ }
700+
664701int gve_adminq_describe_device (struct gve_priv * priv )
665702{
703+ struct gve_device_option_jumbo_frames * dev_op_jumbo_frames = NULL ;
666704 struct gve_device_option_gqi_rda * dev_op_gqi_rda = NULL ;
667705 struct gve_device_option_gqi_qpl * dev_op_gqi_qpl = NULL ;
668706 struct gve_device_option_dqo_rda * dev_op_dqo_rda = NULL ;
669707 struct gve_device_descriptor * descriptor ;
708+ u32 supported_features_mask = 0 ;
670709 union gve_adminq_command cmd ;
671710 dma_addr_t descriptor_bus ;
672711 int err = 0 ;
@@ -690,7 +729,8 @@ int gve_adminq_describe_device(struct gve_priv *priv)
690729 goto free_device_descriptor ;
691730
692731 err = gve_process_device_options (priv , descriptor , & dev_op_gqi_rda ,
693- & dev_op_gqi_qpl , & dev_op_dqo_rda );
732+ & dev_op_gqi_qpl , & dev_op_dqo_rda ,
733+ & dev_op_jumbo_frames );
694734 if (err )
695735 goto free_device_descriptor ;
696736
@@ -705,12 +745,19 @@ int gve_adminq_describe_device(struct gve_priv *priv)
705745 priv -> queue_format = GVE_DQO_RDA_FORMAT ;
706746 dev_info (& priv -> pdev -> dev ,
707747 "Driver is running with DQO RDA queue format.\n" );
748+ supported_features_mask =
749+ be32_to_cpu (dev_op_dqo_rda -> supported_features_mask );
708750 } else if (dev_op_gqi_rda ) {
709751 priv -> queue_format = GVE_GQI_RDA_FORMAT ;
710752 dev_info (& priv -> pdev -> dev ,
711753 "Driver is running with GQI RDA queue format.\n" );
754+ supported_features_mask =
755+ be32_to_cpu (dev_op_gqi_rda -> supported_features_mask );
712756 } else {
713757 priv -> queue_format = GVE_GQI_QPL_FORMAT ;
758+ if (dev_op_gqi_qpl )
759+ supported_features_mask =
760+ be32_to_cpu (dev_op_gqi_qpl -> supported_features_mask );
714761 dev_info (& priv -> pdev -> dev ,
715762 "Driver is running with GQI QPL queue format.\n" );
716763 }
@@ -747,6 +794,9 @@ int gve_adminq_describe_device(struct gve_priv *priv)
747794 }
748795 priv -> default_num_queues = be16_to_cpu (descriptor -> default_num_queues );
749796
797+ gve_enable_supported_features (priv , supported_features_mask ,
798+ dev_op_jumbo_frames );
799+
750800free_device_descriptor :
751801 dma_free_coherent (& priv -> pdev -> dev , PAGE_SIZE , descriptor ,
752802 descriptor_bus );
0 commit comments