The Curiosity rover has a compact X-band high-gain antenna (HGA) that allows for low data rate communication directly with Earth,
but is used though for higher data rates it usually uses UHF to communicate with spacecraft orbiting Mars, which then relay the data back to Earth with their much larger dish antennas. Thanks to @BrendanLuke15 for the correction!
From Section 5.1 and Figure 5-1 on page number 113 of the DESCANSO article linked below:
The uplink communication to the spacecraft is either with X-band DFE with the DSN or UHF through MRO. Downlink, governed by data volume requirements, is UHF relay only, as shown in Figure 5-1.
From Section 2.2, Surface Operations of Article 14 of the DESCANSO Design and Performance Summary Series Mars Science Laboratory Telecommunications System Design one can see that the HGA needs to point in the correct direction within a few degrees;
The HGA sits on a 2 degree-of-freedom gimbal, with 5-deg system pointing accuracy (including rover attitude knowledge), and is 0.28 m in diameter. Table 2-4 shows that the downlink gain is about 4 dB lower and the uplink gain about 3 dB lower, at 5 deg off boresight.
How does Curiosity get its "rover attitude knowledge"? Also, since the position of Earth is moving with respect to Mars, as is that of the satellites around Mars, How does Curiosity know how to slew the antenna correctly in real time? Does it cary an ephemeris which is updated from time to time via uplink?
above: Curiosity's High Gain Antenna (articulated dirty hexagon). Cropped from here.
below: Curiosity's High Gain Antenna gain in uplink and downlink modes, from MSL Telecommunications System Design.